diff options
| author | tv <tv@krebsco.de> | 2026-10-31 05:01:17 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 05:01:17 +0100 |
| commit | 69bc5ae4ce1c0e8ff2fe03091b1ba022edc13ad1 (patch) | |
| tree | 73650e158f1872cb04a42d92da4ff41a2f4edd9e /src/api/peers.rs | |
| parent | 6c7809103f62c89fc10cc82228a28a0f39db5277 (diff) | |
replace EpochInfo by EpochRecord
Diffstat (limited to 'src/api/peers.rs')
| -rw-r--r-- | src/api/peers.rs | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs index 8ebffc5..020221b 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -12,7 +12,7 @@ use tokio::time::Instant; use tracing::warn; use super::store_status; -use crate::document::replica::Epoch; +use crate::document::replica::EpochRecord; use crate::document::store; use crate::locks::MutexExt; use crate::state::{AppState, HelloState, Incidents, Liveness}; @@ -31,23 +31,6 @@ pub(crate) enum PeerLivenessStatus { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] -pub(crate) struct EpochInfo { - pub(crate) generation: u64, - /// Hex-encoded snapshot hash; all zeros for the genesis epoch. - pub(crate) id: String, -} - -impl From<Epoch> for EpochInfo { - fn from(epoch: Epoch) -> Self { - Self { - generation: epoch.generation, - id: epoch.id_hex(), - } - } -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] pub(crate) struct PeerStatus { /// The name the peer gave itself in the member list, if any (not unique). pub(crate) alias: Option<String>, @@ -68,7 +51,7 @@ pub(crate) struct PeerStatus { pub(crate) diverged_for_secs: Option<u64>, pub(crate) has_pending_delivery: bool, /// Epoch the peer last advertised; absent until it has sent a message. - pub(crate) epoch: Option<EpochInfo>, + pub(crate) epoch: Option<EpochRecord>, /// Whether that epoch equals ours, i.e. whether we sync with this peer. pub(crate) same_epoch: Option<bool>, /// Number of heads in its last keepalive; absent before one, or when it had more @@ -99,7 +82,7 @@ pub(crate) struct ThroughputInfo { pub(crate) struct PeerListResponse { /// Our own alias (`--alias`). pub(crate) local_alias: Option<String>, - pub(crate) local_epoch: EpochInfo, + pub(crate) local_epoch: EpochRecord, /// Number of heads of our document. Several heads are concurrent changes no later /// change has merged yet. pub(crate) local_heads: usize, @@ -178,7 +161,7 @@ pub(crate) async fn peer_list(state: &AppState) -> PeerListResponse { .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), + epoch: ps.epoch.map(EpochRecord::from), same_epoch: ps.epoch.map(|epoch| epoch == local_epoch), heads: ps.reported_heads, neighbour, |
