From 69bc5ae4ce1c0e8ff2fe03091b1ba022edc13ad1 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 05:01:17 +0100 Subject: replace EpochInfo by EpochRecord --- src/api/peers.rs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src/api/peers.rs') 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}; @@ -29,23 +29,6 @@ pub(crate) enum PeerLivenessStatus { Dormant, } -#[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 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 { @@ -68,7 +51,7 @@ pub(crate) struct PeerStatus { pub(crate) diverged_for_secs: Option, pub(crate) has_pending_delivery: bool, /// Epoch the peer last advertised; absent until it has sent a message. - pub(crate) epoch: Option, + pub(crate) epoch: Option, /// Whether that epoch equals ours, i.e. whether we sync with this peer. pub(crate) same_epoch: Option, /// 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, - 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, -- cgit v1.3.1