aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/inbound.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-04 19:45:14 +0100
committertv <tv@krebsco.de>2026-11-04 19:45:14 +0100
commit07ef1e4e562d977e72f0a6b702736ae3645b45c7 (patch)
treec48b0917f602d63f95ef195c899069a16380eefb /src/swarm/peer/inbound.rs
parentd2c1fb0b87a4c74a7f18ec9ad0a62e2c195523a0 (diff)
hello again when heard from
While we wait for a peer's HELLO_REPLY, anything else that comes from it makes our HELLO go again at once, at most once a second, instead of when the backoff says.
Diffstat (limited to 'src/swarm/peer/inbound.rs')
-rw-r--r--src/swarm/peer/inbound.rs15
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