Skip to content

Commit c74ef8e

Browse files
committed
collator-protocol: Readvertise collations after peer disconnects
Signed-off-by: Alexandru Vasile <[email protected]>
1 parent e733978 commit c74ef8e

File tree

1 file changed

+29
-0
lines changed
  • polkadot/node/network/collator-protocol/src/collator_side

1 file changed

+29
-0
lines changed

polkadot/node/network/collator-protocol/src/collator_side/mod.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,35 @@ async fn handle_network_msg<Context>(
13751375
unknown_heads: LruMap::new(ByLength::new(10)),
13761376
});
13771377

1378+
// Advertise collations for the current peer in case this is a reconnect.
1379+
//
1380+
// We might try to advertise collation T0 to the peer, then the peer disconnects
1381+
// before receiving the message. Later on, we generate a new collation T1
1382+
// and the peer reconnects. We need to make sure the peer gets T0 advertised as well.
1383+
//
1384+
// The `advertise_collation` ensures we are not readvertising the same collation
1385+
// multiple times.
1386+
if let Some(para_id) = state.collating_on {
1387+
if let Some(implicit_view) = &state.implicit_view {
1388+
gum::trace!(target: LOG_TARGET, ?peer_id, ?para_id, "Checking collations on possible reconnect");
1389+
1390+
for leaf in implicit_view.leaves() {
1391+
if let Some(per_relay_parent) = state.per_relay_parent.get_mut(leaf) {
1392+
advertise_collation(
1393+
ctx,
1394+
*leaf,
1395+
per_relay_parent,
1396+
&peer_id,
1397+
&state.peer_ids,
1398+
&mut state.advertisement_timeouts,
1399+
&state.metrics,
1400+
)
1401+
.await;
1402+
}
1403+
}
1404+
}
1405+
}
1406+
13781407
if let Some(authority_ids) = maybe_authority {
13791408
gum::trace!(
13801409
target: LOG_TARGET,

0 commit comments

Comments
 (0)