Skip to content

fix(syncer): remove duplicate notify_subscribers calls#128

Open
VolodymyrBg wants to merge 1 commit intoSeismicSystems:mainfrom
VolodymyrBg:fix/syncer-remove-duplicate-notify
Open

fix(syncer): remove duplicate notify_subscribers calls#128
VolodymyrBg wants to merge 1 commit intoSeismicSystems:mainfrom
VolodymyrBg:fix/syncer-remove-duplicate-notify

Conversation

@VolodymyrBg
Copy link

The [cache_block()]

summit/syncer/src/actor.rs

Lines 933 to 937 in ca596c1

/// Add a notarized block to the prunable archive.
async fn cache_block(&mut self, round: Round, commitment: B::Commitment, block: B) {
self.notify_subscribers(commitment, &block).await;
self.cache.put_block(round, commitment, block).await;
}
function already calls [notify_subscribers()]

summit/syncer/src/actor.rs

Lines 828 to 834 in ca596c1

async fn notify_subscribers(&mut self, commitment: B::Commitment, block: &B) {
if let Some(mut bs) = self.block_subscriptions.remove(&commitment) {
for subscriber in bs.subscribers.drain(..) {
subscriber.send_lossy(block.clone());
}
}
}
internally, so the explicit calls after it were redundant. While not a bug (the second call was a no-op since subscribers are removed on first call), this removes unnecessary BTreeMap lookups and async function calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant