Have processor's Network::new sleep until booted, not panic

This commit is contained in:
Luke Parker
2023-11-08 01:25:20 -05:00
parent bc07e14b1e
commit a688350f44
3 changed files with 16 additions and 19 deletions

View File

@@ -305,7 +305,13 @@ impl Eq for Bitcoin {}
impl Bitcoin {
pub async fn new(url: String) -> Bitcoin {
Bitcoin { rpc: Rpc::new(url).await.expect("couldn't create a Bitcoin RPC") }
let mut res = Rpc::new(url.clone()).await;
while let Err(e) = res {
log::error!("couldn't connect to Bitcoin node: {e:?}");
tokio::time::sleep(Duration::from_secs(5)).await;
res = Rpc::new(url.clone()).await;
}
Bitcoin { rpc: res.unwrap() }
}
#[cfg(test)]