diff options
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/peers.rs | 25 | ||||
| -rw-r--r-- | src/api/stats.rs | 5 |
2 files changed, 7 insertions, 23 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, diff --git a/src/api/stats.rs b/src/api/stats.rs index 9e1b278..13610dd 100644 --- a/src/api/stats.rs +++ b/src/api/stats.rs @@ -13,7 +13,8 @@ use std::collections::BTreeMap; use serde::Serialize; -use super::peers::{EpochInfo, PeerListResponse, peer_list}; +use super::peers::{PeerListResponse, peer_list}; +use crate::document::replica::EpochRecord; use crate::state::{AppState, Incidents}; use crate::swarm::{members, stability, topology}; use crate::transport::stats::TransportStats; @@ -28,7 +29,7 @@ pub(crate) struct StatsResponse { alias: Option<String>, uptime_secs: u64, ready: bool, - epoch: EpochInfo, + epoch: EpochRecord, document: DocumentStats, catch_up: CatchUpStats, remakes: RemakeStats, |
