diff --git a/coordinator/src/substrate/mod.rs b/coordinator/src/substrate/mod.rs index 33e3381f..fca1fc03 100644 --- a/coordinator/src/substrate/mod.rs +++ b/coordinator/src/substrate/mod.rs @@ -451,19 +451,19 @@ pub async fn scan_task( pub async fn is_active_set(serai: &Serai, set: ValidatorSet) -> bool { // TODO: Track this from the Substrate scanner to reduce our overhead? We'd only have a DB // call, instead of a series of network requests - let latest = loop { - let Ok(res) = serai.latest_block_hash().await else { + let serai = loop { + let Ok(serai) = serai.with_current_latest_block().await else { log::error!( "couldn't get the latest block hash from serai when checking tributary relevancy" ); sleep(Duration::from_secs(5)).await; continue; }; - break res; + break serai.validator_sets(); }; let latest_session = loop { - let Ok(res) = serai.as_of(latest).validator_sets().session(set.network).await else { + let Ok(res) = serai.session(set.network).await else { log::error!("couldn't get the latest session from serai when checking tributary relevancy"); sleep(Duration::from_secs(5)).await; continue; @@ -482,7 +482,7 @@ pub async fn is_active_set(serai: &Serai, set: ValidatorSet) -> bool { } else { // Since the next session has started, check its handover status let keys = loop { - let Ok(res) = serai.as_of(latest).validator_sets().keys(set).await else { + let Ok(res) = serai.keys(set).await else { log::error!( "couldn't get the keys for a session from serai when checking tributary relevancy" ); diff --git a/coordinator/src/tributary/scanner.rs b/coordinator/src/tributary/scanner.rs index fa9c118d..25f1a5dc 100644 --- a/coordinator/src/tributary/scanner.rs +++ b/coordinator/src/tributary/scanner.rs @@ -216,8 +216,8 @@ pub(crate) async fn scan_tributaries_task< // creation // TODO2: Differentiate connection errors from invariants Err(e) => { - if let Ok(latest) = serai.latest_block_hash().await { - let serai = serai.as_of(latest).validator_sets(); + if let Ok(serai) = serai.with_current_latest_block().await { + let serai = serai.validator_sets(); // Check if this failed because the keys were already set by someone // else if matches!(serai.keys(spec.set()).await, Ok(Some(_))) {