diff options
| author | tv <tv@krebsco.de> | 2026-10-23 22:25:41 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-23 22:25:41 +0200 |
| commit | de560ee34ba0297194cae6ac9a1966e3ef614945 (patch) | |
| tree | 58dbdef0c2be5b747991c712c126271bc8ef692a /src/api | |
| parent | d8f0933b5c88634ee7e83b435241084baa6abf5b (diff) | |
bump number of heads in keepalive messages
Instead of arbitrarily limiting the number to 16, allow filling
keepalive messages as long as they don't cause mycelium to chunk it.
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/peers.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs index ce41776..3317185 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -57,12 +57,18 @@ pub(crate) struct PeerStatus { epoch: Option<EpochInfo>, /// Whether that epoch equals ours, i.e. whether we sync with this peer. same_epoch: Option<bool>, + /// 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<usize>, } #[derive(Debug, Serialize, ToSchema)] #[serde(rename_all = "camelCase")] pub(crate) struct PeerListResponse { local_epoch: EpochInfo, + /// Number of heads of our document. Several heads are concurrent changes no later + /// change has merged yet. + local_heads: usize, peers: Vec<PeerStatus>, } @@ -122,12 +128,15 @@ pub(crate) async fn list_peers( has_pending_delivery: ps.sync.outbound.is_some(), epoch: ps.epoch.map(EpochInfo::from), same_epoch: ps.epoch.map(|epoch| epoch == local_epoch), + heads: ps.reported_heads, }); } peers.sort_by(|a, b| a.public_key.cmp(&b.public_key)); + let local_heads = state.doc.write().await.doc.get_heads().len(); Ok(Json(PeerListResponse { local_epoch: local_epoch.into(), + local_heads, peers, })) } |
