Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
retries
  • Loading branch information
kostekIV committed Nov 18, 2022
commit 8f417bd10c9f7b041ea8b56668724fd8edb7dadb
77 changes: 0 additions & 77 deletions aleph-client/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion aleph-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ anyhow = "1.0"
codec = { package = 'parity-scale-codec', version = "3.0.0", features = ['derive'] }
hex = { version = "0.4.3", features = ["alloc"] }
log = "0.4"
rayon = "1.5"
serde_json = { version = "1.0" }
thiserror = "1.0"
contract-metadata = "1.5"
Expand Down
23 changes: 19 additions & 4 deletions aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{thread::sleep, time::Duration};

use anyhow::anyhow;
use codec::Decode;
use log::info;
Expand Down Expand Up @@ -51,12 +53,25 @@ impl SudoCall for RootConnection {
}

impl Connection {
const DEFAULT_RETRIES: u32 = 10;
const RETRY_WAIT_SECS: u64 = 1;

pub async fn new(address: String) -> Self {
let client = Client::from_url(address)
.await
.expect("Should connect to the chain");
Self::new_with_retries(address, Self::DEFAULT_RETRIES).await
}

Self { client }
pub async fn new_with_retries(address: String, mut retries: u32) -> Self {
loop {
let client = Client::from_url(&address).await;
match (retries, client) {
(_, Ok(client)) => return Self { client },
(0, Err(e)) => panic!("{:?}", e),
_ => {
sleep(Duration::from_secs(Self::RETRY_WAIT_SECS));
retries -= 1;
}
}
}
}

pub async fn get_storage_entry<T: DecodeWithMetadata, Defaultable, Iterable>(
Expand Down
77 changes: 0 additions & 77 deletions bin/cliain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion e2e-tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.