mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-16 17:07:35 +00:00
Have processor's Network::new sleep until booted, not panic
This commit is contained in:
parent
bc07e14b1e
commit
a688350f44
3 changed files with 16 additions and 19 deletions
|
@ -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)]
|
||||
|
|
|
@ -192,7 +192,13 @@ fn map_rpc_err(err: RpcError) -> NetworkError {
|
|||
|
||||
impl Monero {
|
||||
pub async fn new(url: String) -> Monero {
|
||||
Monero { rpc: HttpRpc::new(url).await.unwrap() }
|
||||
let mut res = HttpRpc::new(url.clone()).await;
|
||||
while let Err(e) = res {
|
||||
log::error!("couldn't connect to Monero node: {e:?}");
|
||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
res = HttpRpc::new(url.clone()).await;
|
||||
}
|
||||
Monero { rpc: res.unwrap() }
|
||||
}
|
||||
|
||||
fn view_pair(spend: EdwardsPoint) -> ViewPair {
|
||||
|
|
|
@ -50,14 +50,7 @@ mod bitcoin {
|
|||
|
||||
async fn bitcoin(ops: &DockerOperations) -> Bitcoin {
|
||||
let handle = ops.handle("serai-dev-bitcoin").host_port(8332).unwrap();
|
||||
let url = format!("http://serai:seraidex@{}:{}", handle.0, handle.1);
|
||||
for _ in 0 .. 20 {
|
||||
if bitcoin_serai::rpc::Rpc::new(url.clone()).await.is_ok() {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(core::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
let bitcoin = Bitcoin::new(url).await;
|
||||
let bitcoin = Bitcoin::new(format!("http://serai:seraidex@{}:{}", handle.0, handle.1)).await;
|
||||
bitcoin.fresh_chain().await;
|
||||
bitcoin
|
||||
}
|
||||
|
@ -114,15 +107,7 @@ mod monero {
|
|||
|
||||
async fn monero(ops: &DockerOperations) -> Monero {
|
||||
let handle = ops.handle("serai-dev-monero").host_port(18081).unwrap();
|
||||
let url = format!("http://serai:seraidex@{}:{}", handle.0, handle.1);
|
||||
for _ in 0 .. 60 {
|
||||
if monero_serai::rpc::HttpRpc::new(url.clone()).await.is_ok() {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(core::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
let monero = Monero::new(url).await;
|
||||
let monero = Monero::new(format!("http://serai:seraidex@{}:{}", handle.0, handle.1)).await;
|
||||
while monero.get_latest_block_number().await.unwrap() < 150 {
|
||||
monero.mine_block().await;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue