Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Cleanup buffer on timeout
  • Loading branch information
slumber committed Oct 4, 2022
commit 6093b43ce934964f60d875dcfaca3795c768c254
4 changes: 4 additions & 0 deletions node/network/collator-protocol/src/collator_side/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,10 @@ pub(crate) async fn run<Context>(
.last_connected_at
.map_or(false, |timestamp| now - timestamp > RECONNECT_TIMEOUT)
{
// Remove all advertisements from the buffer if the timeout was hit.
// Usually, it shouldn't be necessary as leaves get deactivated, rather
// serves as a safeguard against finality lags.
state.validator_groups_buf.clear_advertisements();
// Returns `None` if connection request is empty.
state.last_connected_at =
connect_to_validators(&mut ctx, &state.validator_groups_buf).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ impl ValidatorGroupsBuffer {
self.should_be_connected.remove(relay_parent);
}

/// Removes all advertisements from the buffer.
pub fn clear_advertisements(&mut self) {
self.should_be_connected.clear();
}

/// Pushes a new group to the buffer along with advertisement, setting all validators
/// bits to 1.
///
Expand Down