aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/peers.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 04:10:37 +0100
committertv <tv@krebsco.de>2026-10-31 04:10:37 +0100
commit987ba0ffc6a272d5b426e6b91da18f49b480537a (patch)
tree5260dab6e23fed46d4856b89ebd1ecd9721158bc /src/api/peers.rs
parent47e00e5fde46b3460bf12097079e2510967c7010 (diff)
prometheus: build per-peer series from /peers
Diffstat (limited to 'src/api/peers.rs')
-rw-r--r--src/api/peers.rs56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs
index 2f93a43..b425ba6 100644
--- a/src/api/peers.rs
+++ b/src/api/peers.rs
@@ -32,9 +32,9 @@ pub(crate) enum PeerLivenessStatus {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct EpochInfo {
- generation: u64,
+ pub(crate) generation: u64,
/// Hex-encoded snapshot hash; all zeros for the genesis epoch.
- id: String,
+ pub(crate) id: String,
}
impl From<Epoch> for EpochInfo {
@@ -50,63 +50,63 @@ impl From<Epoch> for EpochInfo {
#[serde(rename_all = "camelCase")]
pub(crate) struct PeerStatus {
/// The name the peer gave itself in the member list, if any (not unique).
- alias: Option<String>,
+ pub(crate) alias: Option<String>,
/// Where this node reaches it, or would (`Transport::addresses_of`).
- addresses: Vec<String>,
+ pub(crate) addresses: Vec<String>,
/// Where messages to it go now: the address, whether the peer proved itself there,
/// and the connection there (libp2p: direct or relayed). Absent if nowhere.
- destination: Option<Destination>,
- validated_swarm: Option<String>,
- status: PeerLivenessStatus,
- handshake_complete: bool,
- last_seen_secs_ago: Option<u64>,
- dormant_for_secs: Option<u64>,
+ pub(crate) destination: Option<Destination>,
+ pub(crate) validated_swarm: Option<String>,
+ pub(crate) status: PeerLivenessStatus,
+ pub(crate) handshake_complete: bool,
+ pub(crate) last_seen_secs_ago: Option<u64>,
+ pub(crate) dormant_for_secs: Option<u64>,
/// Since a sync message from it was applied (or the epoch changed).
- last_sync_secs_ago: Option<u64>,
+ pub(crate) 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,
+ 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.
- epoch: Option<EpochInfo>,
+ pub(crate) epoch: Option<EpochInfo>,
/// Whether that epoch equals ours, i.e. whether we sync with this peer.
- same_epoch: Option<bool>,
+ pub(crate) 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 and some of them are sent).
- heads: Option<usize>,
+ pub(crate) heads: Option<usize>,
/// We keep it alive and sync with it on our own; other peers we only answer.
- neighbour: bool,
+ pub(crate) neighbour: bool,
/// Messages and payload bytes exchanged with it, by kind, since we started (or
/// since it was last listed).
- traffic: PeerTraffic,
- incidents: Incidents,
+ pub(crate) traffic: PeerTraffic,
+ pub(crate) incidents: Incidents,
/// Smoothed sync throughput (`swarm::throughput`); absent before the first large
/// exchange.
- sync_throughput: Option<ThroughputInfo>,
+ pub(crate) sync_throughput: Option<ThroughputInfo>,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ThroughputInfo {
- bytes_per_sec: f64,
- samples: u32,
+ pub(crate) bytes_per_sec: f64,
+ pub(crate) samples: u32,
/// Age of the last sample.
- secs_ago: u64,
+ pub(crate) secs_ago: u64,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct PeerListResponse {
/// Our own alias (`--alias`).
- local_alias: Option<String>,
- local_epoch: EpochInfo,
+ pub(crate) local_alias: Option<String>,
+ pub(crate) local_epoch: EpochInfo,
/// Number of heads of our document. Several heads are concurrent changes no later
/// change has merged yet.
- local_heads: usize,
+ pub(crate) local_heads: usize,
/// Where this node can be reached (`Transport::local_addresses`).
- local_addresses: Vec<String>,
+ pub(crate) local_addresses: Vec<String>,
/// By node ID.
- peers: BTreeMap<String, PeerStatus>,
+ pub(crate) peers: BTreeMap<String, PeerStatus>,
}
#[derive(Debug, Deserialize)]