Skip to content

Commit

Permalink
fix: log only when dapp address list changes
Browse files Browse the repository at this point in the history
This applies only to the experimental multi-dapp claimer

Co-authored-by: Marcel Moura <[email protected]>
  • Loading branch information
renan061 and marcelstanley committed Aug 23, 2024
1 parent e78c862 commit 3e3690a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions offchain/authority-claimer/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rollups_events::{
RollupsClaimsStream, INITIAL_ID,
};
use snafu::ResultExt;
use std::{collections::HashMap, fmt::Debug};
use std::{collections::HashMap, collections::HashSet, fmt::Debug};

/// The `BrokerListener` listens for new claims from the broker.
#[async_trait]
Expand Down Expand Up @@ -119,11 +119,22 @@ impl MultidappBrokerListener {
// Gets the dapps from the broker.
let dapps = self.broker.get_dapps().await.context(BrokerSnafu)?;
assert!(!dapps.is_empty());
tracing::info!(
"Got the following dapps from key \"{}\": {:?}",
rollups_events::DAPPS_KEY,
dapps
);
{
// Logging if the dapps changed.
let old_dapps: HashSet<Address> = self
.streams
.iter()
.map(|(stream, _)| stream.dapp_address.clone())
.collect();
let new_dapps = HashSet::from_iter(dapps.clone());
if old_dapps != new_dapps {
tracing::info!(
"Updated list of dapp addresses from key \"{}\": {:?}",
rollups_events::DAPPS_KEY,
new_dapps
);
}
}

// Converts dapps to streams.
let streams: Vec<_> = dapps
Expand Down

0 comments on commit 3e3690a

Please sign in to comment.