diff options
Diffstat (limited to 'src/swarm/peer/inbound.rs')
| -rw-r--r-- | src/swarm/peer/inbound.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs index 28066cb..cfafbd3 100644 --- a/src/swarm/peer/inbound.rs +++ b/src/swarm/peer/inbound.rs @@ -68,13 +68,19 @@ pub(crate) async fn handle_message( // one does). When we heard from it before tells a restarted peer how long it was // away (in our HELLO_REPLY). let peer_state = state.get_or_create_peer_state(&peer).await; + let mut hello_now = false; let (reactivated, previously_seen) = heard_from(state, &peer, &peer_state, Instant::now(), |peer_state| { - if let Some(run) = run { - peer_state.returned(run); + match run { + Some(run) => peer_state.returned(run), + // Up and reaching us, while we wait for its HELLO_REPLY. + None => hello_now = peer_state.hello_again_now(Instant::now()), } }) .await; + if hello_now { + state.peers_due.now(); + } let same_epoch = observe_peer_epoch(state, &peer, epoch, epoch_seq, run).await; match message { @@ -83,7 +89,12 @@ pub(crate) async fn handle_message( // restart. It becomes a member right away; our reply makes us one for it. let Some(swarm_id) = state.swarm_id().await else { // We are joining ourselves; the peer retries until we know our swarm. + // It is up and reaches us: if we wait for its HELLO_REPLY, our HELLO or + // the reply was lost, and ours goes again now. debug!(peer = %peer, "HELLO before we know our swarm; not answering yet"); + if peer_state.lock().await.hello_again_now(Instant::now()) { + state.peers_due.now(); + } return Ok(()); }; if let Some(theirs) = &hello.swarm_id |
