summaryrefslogtreecommitdiffstats
path: root/src/api/peers.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-24 06:53:17 +0200
committertv <tv@krebsco.de>2026-10-24 06:53:17 +0200
commit8ee3b7f0d2f9b76cb24f0049431bd58d09d6c5a4 (patch)
tree6e9774ff74634029309e6720e7c8eccce62766cf /src/api/peers.rs
parenteeae01887aa7bf5ab4dc4d9c5dc90e06c465accd (diff)
add node aliases
Diffstat (limited to 'src/api/peers.rs')
-rw-r--r--src/api/peers.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs
index 0305647..7caaaf3 100644
--- a/src/api/peers.rs
+++ b/src/api/peers.rs
@@ -48,6 +48,8 @@ impl From<Epoch> for EpochInfo {
#[serde(rename_all = "camelCase")]
pub(crate) struct PeerStatus {
public_key: String,
+ /// The name the peer gave itself in the member list, if any (not unique).
+ alias: Option<String>,
validated_swarm: Option<String>,
status: PeerLivenessStatus,
handshake_complete: bool,
@@ -87,6 +89,8 @@ pub(crate) struct ThroughputInfo {
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub(crate) struct PeerListResponse {
+ /// Our own alias (`--alias`).
+ local_alias: Option<String>,
local_epoch: EpochInfo,
/// Number of heads of our document. Several heads are concurrent changes no later
/// change has merged yet.
@@ -125,6 +129,7 @@ pub(crate) async fn list_peers(
let now = Instant::now();
let local_epoch = state.local_epoch();
+ let mut aliases = crate::swarm::members::aliases(&state.doc.read().await.doc);
let mut peers = Vec::with_capacity(snapshot.len());
for (public_key, peer_state_mutex) in snapshot {
@@ -155,6 +160,7 @@ pub(crate) async fn list_peers(
};
peers.push(PeerStatus {
+ alias: aliases.remove(&public_key),
public_key,
validated_swarm: ps.standing.swarm_id().map(str::to_owned),
status,
@@ -178,6 +184,7 @@ pub(crate) async fn list_peers(
peers.sort_by(|a, b| a.public_key.cmp(&b.public_key));
let local_heads = state.doc.write().await.doc.get_heads().len();
Ok(Json(PeerListResponse {
+ local_alias: state.alias.clone(),
local_epoch: local_epoch.into(),
local_heads,
peers,