File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 25
25
std:: {
26
26
path:: PathBuf ,
27
27
sync:: Arc ,
28
- time:: Duration ,
28
+ time:: {
29
+ Duration ,
30
+ Instant ,
31
+ } ,
29
32
} ,
30
33
tokio:: {
31
34
net:: TcpStream ,
@@ -115,7 +118,6 @@ struct RelayerSessionTask {
115
118
116
119
impl RelayerSessionTask {
117
120
pub async fn run ( & mut self ) {
118
- let mut failure_count = 0 ;
119
121
let initial_interval = Duration :: from_millis ( 100 ) ;
120
122
let max_interval = Duration :: from_secs ( 5 ) ;
121
123
let mut backoff = ExponentialBackoffBuilder :: new ( )
@@ -124,13 +126,23 @@ impl RelayerSessionTask {
124
126
. with_max_elapsed_time ( None )
125
127
. build ( ) ;
126
128
129
+ const FAILURE_RESET_TIME : Duration = Duration :: from_secs ( 300 ) ;
130
+ let mut first_failure_time = Instant :: now ( ) ;
131
+ let mut failure_count = 0 ;
132
+
127
133
loop {
128
134
match self . run_relayer_connection ( ) . await {
129
135
Ok ( ( ) ) => {
130
136
tracing:: info!( "relayer session graceful shutdown" ) ;
131
137
return ;
132
138
}
133
139
Err ( e) => {
140
+ if first_failure_time. elapsed ( ) > FAILURE_RESET_TIME {
141
+ failure_count = 0 ;
142
+ first_failure_time = Instant :: now ( ) ;
143
+ backoff. reset ( ) ;
144
+ }
145
+
134
146
failure_count += 1 ;
135
147
let next_backoff = backoff. next_backoff ( ) . unwrap_or ( max_interval) ;
136
148
tracing:: error!(
You can’t perform that action at this time.
0 commit comments