diff options
| author | tv <tv@krebsco.de> | 2026-11-03 07:37:02 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-03 07:37:02 +0100 |
| commit | 6aec18f10a965797a862360fde3dc8413e529d28 (patch) | |
| tree | 0cc4194723de1fef55a25fc1d5e8574c130b1bfc /src/swarm/links.rs | |
| parent | 09d6278fd5ce885540ff50f412fc9728322acef7 (diff) | |
links: only news pass on
Diffstat (limited to 'src/swarm/links.rs')
| -rw-r--r-- | src/swarm/links.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/swarm/links.rs b/src/swarm/links.rs index c430d58..54f18c6 100644 --- a/src/swarm/links.rs +++ b/src/swarm/links.rs @@ -899,15 +899,21 @@ pub(crate) fn received(state: &AppState, peer: &str, reply: LinksReply) { route.arrived = true; } // Not older news over newer. - if inner - .replies - .get(&member) - .is_some_and(|(known, _)| *known > at) - { + let known = inner.replies.get(&member); + if known.is_some_and(|(known, _)| *known > at) { return; } + // The same links as we have, lately: no news, so not passed on. A copy that + // went round between relays (each asking the other for the member) comes + // back a little newer each time, as its age counts from when each sent it: + // passed on, it would go round for good. + let news = known.is_none_or(|(known_at, known_links)| { + *known_links != links || now.saturating_duration_since(*known_at) >= REPLY_WITHIN + }); inner.replies.insert(member.clone(), (at, links)); - arrived.push(member); + if news { + arrived.push(member); + } }; if own { keep(peer.to_owned(), Duration::ZERO, reply.links); |
