bitcoind: only sleep on error if there is >0 retries

Don't sleep if we won't retry.
This commit is contained in:
Antoine Poinsot 2022-11-09 17:40:06 +01:00
parent 51ff7d6734
commit 45d601282f
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -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),