Tidy Serai use in coordinator to new API

This commit is contained in:
Luke Parker 2023-10-14 02:59:22 -04:00
parent 530fba51dd
commit e3e9939eaf
2 changed files with 7 additions and 7 deletions

View file

@ -451,19 +451,19 @@ pub async fn scan_task<D: Db, Pro: Processors>(
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"
);

View file

@ -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(_))) {