diff options
| author | tv <tv@krebsco.de> | 2026-10-24 04:16:56 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 04:16:56 +0200 |
| commit | 9db1bb81fa470a41434a92a199a92ab78d7b3b7d (patch) | |
| tree | ddbfb06f2b2d3240f33a6c6df2833fed1a93f8ec /src/swarm/sync.rs | |
| parent | 58bc4071f2c2cf53b994783ced94d7083a50ea32 (diff) | |
sync with neighbours
Diffstat (limited to 'src/swarm/sync.rs')
| -rw-r--r-- | src/swarm/sync.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index e05d275..b8d16aa 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -85,6 +85,14 @@ async fn deliver_sync_to_peer(state: &AppState, peer: &str) -> Result<()> { return Ok(()); } + if peer_state.sync.state.their_heads.is_none() + && !crate::swarm::topology::is_neighbour(state, peer) + { + // We only answer peers that aren't our neighbours. + trace!("Not opening sync with a peer that isn't our neighbour"); + return Ok(()); + } + swarm_id.clone() }; @@ -444,8 +452,12 @@ pub(crate) async fn run_sync_worker(state: AppState, mut rx: mpsc::UnboundedRece peers_guard.keys().cloned().collect() }; + // Our own changes go to our neighbours; they pass them on. Others only get + // answers to what they send us. for peer in peer_keys { - if peer_swarm(&state, &peer).await.is_some() { + if peer_swarm(&state, &peer).await.is_some() + && crate::swarm::topology::is_neighbour(&state, &peer) + { dirty_peers.insert(peer); } } |
