From 45d601282fd4e722ad8558243c4b8c9c1ad11345 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 9 Nov 2022 17:40:06 +0100 Subject: [PATCH] bitcoind: only sleep on error if there is >0 retries Don't sleep if we won't retry. --- src/bitcoin/d/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bitcoin/d/mod.rs b/src/bitcoin/d/mod.rs index f0157b18..52fbed1d 100644 --- a/src/bitcoin/d/mod.rs +++ b/src/bitcoin/d/mod.rs @@ -219,8 +219,10 @@ impl BitcoinD { Some(simple_http::Error::Timeout) | Some(simple_http::Error::SocketError(_)) | Some(simple_http::Error::HttpErrorCode(503)) => { - std::thread::sleep(Duration::from_secs(1)); - log::debug!("Retrying RPC request to bitcoind: attempt #{}", i); + if i <= self.retries { + std::thread::sleep(Duration::from_secs(1)); + log::debug!("Retrying RPC request to bitcoind: attempt #{}", i); + } error = Some(e); } _ => return Err(e),