summaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/peers.rs11
-rw-r--r--src/api/stats/prometheus.rs5
-rw-r--r--src/api/store.rs8
3 files changed, 13 insertions, 11 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs
index 9af24c0..f0fd1d9 100644
--- a/src/api/peers.rs
+++ b/src/api/peers.rs
@@ -186,15 +186,14 @@ pub(crate) async fn delete_peer(
.map_err(|_| StatusCode::BAD_REQUEST)?;
// Unknown locally is fine: other nodes may still know the peer.
- if let Some(peer_state_mutex) = state.get_peer_state(&peer).await {
- if peer_state_mutex
+ if let Some(peer_state_mutex) = state.get_peer_state(&peer).await
+ && peer_state_mutex
.lock()
.await
.is_alive(&state.timing, Instant::now())
- && !force.allows("alive")
- {
- return Err(StatusCode::CONFLICT);
- }
+ && !force.allows("alive")
+ {
+ return Err(StatusCode::CONFLICT);
}
let record =
diff --git a/src/api/stats/prometheus.rs b/src/api/stats/prometheus.rs
index 3baa125..30bb966 100644
--- a/src/api/stats/prometheus.rs
+++ b/src/api/stats/prometheus.rs
@@ -181,6 +181,9 @@ fn traffic_series(traffic: &PeerTraffic) -> Vec<(&'static str, &'static str, Cou
series
}
+/// A per-peer incident counter: its name, its help and how to read it.
+type IncidentSeries = (&'static str, &'static str, fn(&Incidents) -> f64);
+
pub(super) async fn render(state: &AppState, stats: &StatsResponse) -> String {
let mut out = Out::default();
@@ -619,7 +622,7 @@ pub(super) async fn render(state: &AppState, stats: &StatsResponse) -> String {
}
}
- let incidents: [(&str, &str, fn(&Incidents) -> f64); 4] = [
+ let incidents: [IncidentSeries; 4] = [
(
"peer_reply_timeouts_total",
"Sync messages unanswered until the reply timeout.",
diff --git a/src/api/store.rs b/src/api/store.rs
index a05bc23..d0fc807 100644
--- a/src/api/store.rs
+++ b/src/api/store.rs
@@ -144,10 +144,10 @@ fn mark_source(
response.headers_mut().insert(HEADS_HEADER, value);
}
}
- if let ReadSource::Stale(epoch) = source {
- if let Ok(value) = HeaderValue::from_str(&epoch.to_string()) {
- response.headers_mut().insert(STALE_HEADER, value);
- }
+ if let ReadSource::Stale(epoch) = source
+ && let Ok(value) = HeaderValue::from_str(&epoch.to_string())
+ {
+ response.headers_mut().insert(STALE_HEADER, value);
}
Ok(response)
}