Skip to content

Commit

Permalink
Refactor swarm event metric recording
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Aug 21, 2023
1 parent bf6b753 commit cf79259
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions misc/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
.map(|k| k.bootstrap());
}

match swarm.next().await.expect("Swarm not to terminate.") {
let event = swarm.next().await.expect("Swarm not to terminate.");
metrics.record(&event);
match event {
SwarmEvent::Behaviour(behaviour::BehaviourEvent::Identify(e)) => {
info!("{:?}", e);
metrics.record(&e);
Expand Down Expand Up @@ -202,13 +204,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
// TODO: Add metric recording for `NatStatus`.
// metrics.record(&e)
}
e => {
if let SwarmEvent::NewListenAddr { address, .. } = &e {
println!("Listening on {address:?}");
}

metrics.record(&e)
SwarmEvent::NewListenAddr { address, .. } => {
println!("Listening on {address:?}");
}
_ => {}
}
}
}

0 comments on commit cf79259

Please sign in to comment.