diff options
| author | tv <tv@krebsco.de> | 2026-10-24 19:29:00 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 19:29:55 +0200 |
| commit | 377d3b2fa3c2e9f67abe14f2ef9d6f167caa2fa1 (patch) | |
| tree | d150e20a5130828f0881aa7f4bd5f09b2aef55c9 /src | |
| parent | 815ec2e9a641ad5ac5c2f886291e63c89966bd6c (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')
| -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, ))) |
