Skip to content

Commit a73178f

Browse files
committed
Retry syncing sooner following errors
1 parent 00a1660 commit a73178f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/app.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ impl App {
177177

178178
/// Start a sync loop blocking the current thread
179179
pub fn sync_loop(&self, shutdown_rx: Option<mpsc::Receiver<()>>) {
180+
const RETRY_DUR: Duration = Duration::from_secs(3);
181+
180182
let shutdown_rx = shutdown_rx
181183
.map(|rx| self.bind_shutdown(rx))
182184
.or_else(|| self.default_shutdown_signal());
@@ -189,18 +191,18 @@ impl App {
189191
}
190192
}
191193

194+
let mut wait_time = self.config.poll_interval;
195+
192196
if let Err(e) = self.sync() {
193-
warn!(target: LT, "failed syncing with bitcoind: {:?}", e);
194197
// Report the error and try again on the next run, this might be
195198
// a temporary connectivity issue.
199+
warn!(target: LT, "failed syncing with bitcoind: {:?}", e);
200+
wait_time = RETRY_DUR;
196201
}
197202

198203
// wait for poll_interval seconds or until we receive a sync notification message
199204
// (which can also get triggered through the shutdown signal)
200-
self.sync_chan
201-
.1
202-
.recv_timeout(self.config.poll_interval)
203-
.ok();
205+
self.sync_chan.1.recv_timeout(wait_time).ok();
204206
}
205207
}
206208

0 commit comments

Comments
 (0)