aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/peers.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 04:09:40 +0100
committertv <tv@krebsco.de>2026-10-31 04:09:40 +0100
commit47e00e5fde46b3460bf12097079e2510967c7010 (patch)
treeb0adc280cf36f45563fc30653ecb04021dc487b4 /src/api/peers.rs
parent4be01038984c7c31433a20201de5638f23f4f2fb (diff)
add lastSyncSecsAgo and description to /peers
Diffstat (limited to 'src/api/peers.rs')
-rw-r--r--src/api/peers.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs
index da714d0..2f93a43 100644
--- a/src/api/peers.rs
+++ b/src/api/peers.rs
@@ -61,6 +61,11 @@ pub(crate) struct PeerStatus {
handshake_complete: bool,
last_seen_secs_ago: Option<u64>,
dormant_for_secs: Option<u64>,
+ /// Since a sync message from it was applied (or the epoch changed).
+ last_sync_secs_ago: Option<u64>,
+ /// How long its heads have differed from ours with no sync message from it in
+ /// between; absent while they match.
+ diverged_for_secs: Option<u64>,
has_pending_delivery: bool,
/// Epoch the peer last advertised; absent until it has sent a message.
epoch: Option<EpochInfo>,
@@ -166,6 +171,12 @@ pub(crate) async fn peer_list(state: &AppState) -> PeerListResponse {
.last_seen
.map(|t| now.saturating_duration_since(t).as_secs()),
dormant_for_secs,
+ last_sync_secs_ago: ps
+ .last_sync_rx
+ .map(|t| now.saturating_duration_since(t).as_secs()),
+ diverged_for_secs: ps
+ .diverged_since
+ .map(|t| now.saturating_duration_since(t).as_secs()),
has_pending_delivery: ps.sync.sending.is_some() || ps.sync.retry_at.is_some(),
epoch: ps.epoch.map(EpochInfo::from),
same_epoch: ps.epoch.map(|epoch| epoch == local_epoch),