Skip to content

Commit

Permalink
ref(iroh-net): Don't write the match as fully exhaustive (#2585)
Browse files Browse the repository at this point in the history
## Description

This makes it a bit earier to read.  It's harder to figure out if thre
are changes to the ConnectionType though, but let's assume that
doesn't happen too often.


## Breaking Changes

None

## Notes & open questions

I'm open to other ways of structuring this code.  Not entirely sure
what the best shape would be.

## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
  • Loading branch information
flub authored Aug 5, 2024
1 parent f5b3918 commit 43ef8b6
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions iroh-net/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,46 +303,31 @@ impl NodeState {

// Update some metrics
match (prev_typ, typ) {
(ConnectionType::Direct(_), ConnectionType::Direct(_)) => (),
(ConnectionType::Direct(_), ConnectionType::Relay(_)) => {
inc!(MagicsockMetrics, num_direct_conns_removed);
inc!(MagicsockMetrics, num_relay_conns_added);
}
(ConnectionType::Direct(_), ConnectionType::Mixed(_, _)) => {
inc!(MagicsockMetrics, num_direct_conns_removed);
inc!(MagicsockMetrics, num_relay_conns_added);
}
(ConnectionType::Direct(_), ConnectionType::None) => {
inc!(MagicsockMetrics, num_direct_conns_removed)
}
(ConnectionType::Relay(_), ConnectionType::Direct(_)) => {
inc!(MagicsockMetrics, num_direct_conns_added);
inc!(MagicsockMetrics, num_relay_conns_removed);
}
(ConnectionType::Relay(_), ConnectionType::Relay(_)) => (),
(ConnectionType::Relay(_), ConnectionType::Mixed(_, _)) => (),
(ConnectionType::Relay(_), ConnectionType::None) => {
inc!(MagicsockMetrics, num_relay_conns_removed)
}
(ConnectionType::Mixed(_, _), ConnectionType::Direct(_)) => {
(ConnectionType::Relay(_), ConnectionType::Direct(_))
| (ConnectionType::Mixed(_, _), ConnectionType::Direct(_)) => {
inc!(MagicsockMetrics, num_direct_conns_added);
inc!(MagicsockMetrics, num_relay_conns_removed);
}
(ConnectionType::Mixed(_, _), ConnectionType::Relay(_)) => (),
(ConnectionType::Mixed(_, _), ConnectionType::Mixed(_, _)) => (),
(ConnectionType::Mixed(_, _), ConnectionType::None) => {
inc!(MagicsockMetrics, num_relay_conns_removed)
(ConnectionType::Direct(_), ConnectionType::Relay(_))
| (ConnectionType::Direct(_), ConnectionType::Mixed(_, _)) => {
inc!(MagicsockMetrics, num_direct_conns_removed);
inc!(MagicsockMetrics, num_relay_conns_added);
}
(ConnectionType::None, ConnectionType::Direct(_)) => {
inc!(MagicsockMetrics, num_direct_conns_added)
}
(ConnectionType::None, ConnectionType::Relay(_)) => {
inc!(MagicsockMetrics, num_relay_conns_added)
(ConnectionType::Direct(_), ConnectionType::None) => {
inc!(MagicsockMetrics, num_direct_conns_removed)
}
(ConnectionType::None, ConnectionType::Mixed(_, _)) => {
(ConnectionType::None, ConnectionType::Relay(_))
| (ConnectionType::None, ConnectionType::Mixed(_, _)) => {
inc!(MagicsockMetrics, num_relay_conns_added)
}
(ConnectionType::None, ConnectionType::None) => (),
(ConnectionType::Relay(_), ConnectionType::None)
| (ConnectionType::Mixed(_, _), ConnectionType::None) => {
inc!(MagicsockMetrics, num_relay_conns_removed)
}
_ => (),
}
}
(best_addr, relay_url)
Expand Down

0 comments on commit 43ef8b6

Please sign in to comment.