diff options
| author | tv <tv@krebsco.de> | 2026-10-24 19:29:00 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 19:29:00 +0200 |
| commit | 859b3d0a361f883380a381a3a87d6286dbdd2db0 (patch) | |
| tree | 62376f6c3e624f112473c43c9f4c83051eff22f1 /src/swarm/sync.rs | |
| parent | c8efbab8e351cbb533718260705b2fb65c85b3a4 (diff) | |
being caught up needs some heads
A sync message from a ready peer only completes the initial sync if that
peer has at least one head. A peer with an empty document can no longer
make a joiner ready on an empty store: a misconfigured second swarm, or
a genesis node in its first seconds.
Effect on a brand-new swarm: a joiner now waits until the genesis node
has registered itself in the member list, which happens within about 5 s
of it becoming ready.
Diffstat (limited to 'src/swarm/sync.rs')
| -rw-r--r-- | src/swarm/sync.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 58a08db..17e25c4 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -378,8 +378,11 @@ pub(crate) async fn handle_sync( } Ok(Some(( - // Only from a ready peer: a peer still catching up has empty heads, which - // every document "contains". + // Only from a ready peer, and only if it has heads at all: empty heads are + // "contained" in every document, so they prove nothing. A peer still + // catching up has them, and so does a ready peer whose document is empty + // (a misconfigured second swarm, or a genesis node in its first seconds, + // before it registered itself). check_caught_up && from_ready && peer_state @@ -388,9 +391,10 @@ pub(crate) async fn handle_sync( .their_heads .as_ref() .is_some_and(|heads| { - heads - .iter() - .all(|h| replica.doc.get_change_by_hash(h).is_some()) + !heads.is_empty() + && heads + .iter() + .all(|h| replica.doc.get_change_by_hash(h).is_some()) }), changed, ))) |
