aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/peers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/peers.rs')
-rw-r--r--src/api/peers.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs
index eeb3fb2..da714d0 100644
--- a/src/api/peers.rs
+++ b/src/api/peers.rs
@@ -114,6 +114,12 @@ pub(crate) struct DeletePeerQuery {
pub(crate) async fn list_peers(
State(state): State<AppState>,
) -> Result<Json<PeerListResponse>, StatusCode> {
+ Ok(Json(peer_list(&state).await))
+}
+
+/// What `GET /peers` answers, for others to show too (the dashboard).
+pub(crate) async fn peer_list(state: &AppState) -> PeerListResponse {
+ let state = state.clone();
let snapshot = state.peers_snapshot().await;
let now = Instant::now();
@@ -173,13 +179,13 @@ pub(crate) async fn list_peers(
}
let local_heads = state.doc.read().await.heads().len();
- Ok(Json(PeerListResponse {
+ PeerListResponse {
local_alias: state.alias.clone(),
local_addresses: state.transport.local_addresses(),
local_epoch: local_epoch.into(),
local_heads,
peers,
- }))
+ }
}
/// `DELETE /peers/{pk}`: forgets a peer swarm-wide.