From 5710d1a367a1914d09e0eefe6984408c95a7dd2e Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 04:16:56 +0200 Subject: sync with neighbours --- src/api/peers.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/api/peers.rs') diff --git a/src/api/peers.rs b/src/api/peers.rs index 6a9a271..d381395 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -60,6 +60,8 @@ pub(crate) struct PeerStatus { /// Number of heads in its last keepalive; absent before one, or when it had more /// than 32 (then only their digest is sent). heads: Option, + /// We keep it alive and sync with it on our own; other peers we only answer. + neighbour: bool, } #[derive(Debug, Serialize, ToSchema)] @@ -106,6 +108,7 @@ pub(crate) async fn list_peers( let mut peers = Vec::with_capacity(snapshot.len()); for (public_key, peer_state_mutex) in snapshot { + let neighbour = crate::swarm::topology::is_neighbour(&state, &public_key); let ps = peer_state_mutex.lock().await; let (status, dormant_for_secs) = match ps.liveness { @@ -129,6 +132,7 @@ pub(crate) async fn list_peers( epoch: ps.epoch.map(EpochInfo::from), same_epoch: ps.epoch.map(|epoch| epoch == local_epoch), heads: ps.reported_heads, + neighbour, }); } -- cgit v1.3.1