Skip to content

Commit

Permalink
Add 45 second timeout when checking for jumpstarts
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Aug 14, 2024
1 parent 39cb22e commit 133fefa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ anyhow ="1.0.86"

# Only for the browser
js-sys={ version="0.3.70", optional=true }
tokio ="1.39"
tokio ={ version="1.39", features=["time"] }

[dev-dependencies]
serial_test ="3.1.1"
Expand Down
12 changes: 12 additions & 0 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ pub async fn jumpstart_network(
api: &OnlineClient<EntropyConfig>,
rpc: &LegacyRpcMethods<EntropyConfig>,
signer: sr25519::Pair,
) -> Result<(), ClientError> {
// We split the implementation out into an inner function so that we can more easily pass a
// single future to the `timeout`
tokio::time::timeout(std::time::Duration::from_secs(45), jumpstart_inner(api, rpc, signer))
.await
.map_err(|_| ClientError::JumpstartTimeout)?
}

async fn jumpstart_inner(
api: &OnlineClient<EntropyConfig>,
rpc: &LegacyRpcMethods<EntropyConfig>,
signer: sr25519::Pair,
) -> Result<(), ClientError> {
// In this case we don't care too much about the result because we're more interested in the
// `FinishedNetworkJumpStart` event, which happens later on.
Expand Down
2 changes: 2 additions & 0 deletions crates/client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub enum ClientError {
Subxt(#[from] subxt::Error),
#[error("Timed out waiting for register confirmation")]
RegistrationTimeout,
#[error("Timed out waiting for jumpstart confirmation")]
JumpstartTimeout,
#[error("Cannot get subgroup: {0}")]
SubgroupGet(#[from] SubgroupGetError),
#[error("JSON: {0}")]
Expand Down

0 comments on commit 133fefa

Please sign in to comment.