Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Buffered connection management for collator-protocol #6022

Merged
merged 23 commits into from
Oct 5, 2022
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
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)
eskimor marked this conversation as resolved.
Show resolved Hide resolved
{
// 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();
eskimor marked this conversation as resolved.
Show resolved Hide resolved
// 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