|
8 | 8 | use std::{collections::BTreeMap, net::SocketAddr};
|
9 | 9 |
|
10 | 10 | use n0_future::time::Instant;
|
11 |
| -use tracing::debug; |
| 11 | +use tracing::{Level, event}; |
12 | 12 |
|
13 | 13 | use super::{IpPort, path_state::PathState};
|
14 | 14 |
|
@@ -114,20 +114,34 @@ impl NodeUdpPaths {
|
114 | 114 | &self.best
|
115 | 115 | }
|
116 | 116 |
|
117 |
| - /// Change the current best address(es) to ones chosen as described in [`Self::best_addr`] docs. |
| 117 | + /// Changes the current best address(es) to ones chosen as described in [`Self::best_addr`] docs. |
| 118 | + /// |
| 119 | + /// Returns whether one of the best addresses had to change. |
118 | 120 | ///
|
119 | 121 | /// This should be called any time that `paths` is modified.
|
120 |
| - pub(super) fn update_to_best_addr(&mut self, now: Instant) { |
| 122 | + pub(super) fn update_to_best_addr(&mut self, now: Instant) -> bool { |
121 | 123 | let best_ipv4 = self.best_addr(false, now);
|
122 | 124 | let best = self.best_addr(true, now);
|
| 125 | + let mut changed = false; |
123 | 126 | if best_ipv4 != self.best_ipv4 {
|
124 |
| - debug!(?best_ipv4, "update best addr (IPv4)"); |
| 127 | + event!( |
| 128 | + target: "iroh::_events::udp::best_ipv4", |
| 129 | + Level::DEBUG, |
| 130 | + ?best_ipv4, |
| 131 | + ); |
| 132 | + changed = true; |
125 | 133 | }
|
126 | 134 | if best != self.best {
|
127 |
| - debug!(?best, "update best addr (IPv4 or IPv6)"); |
| 135 | + event!( |
| 136 | + target: "iroh::_events::udp::best", |
| 137 | + Level::DEBUG, |
| 138 | + ?best, |
| 139 | + ); |
| 140 | + changed = true; |
128 | 141 | }
|
129 | 142 | self.best_ipv4 = best_ipv4;
|
130 | 143 | self.best = best;
|
| 144 | + changed |
131 | 145 | }
|
132 | 146 |
|
133 | 147 | /// Returns the current best address of all available paths, ignoring
|
|
0 commit comments