Skip to content

Commit d22c1cd

Browse files
authored
refactor(iroh-net): Remove incremental state from reportgen actor (#2180)
## Description The reportgen actor was carrying this "incremental" state around in two ways: as an Option in last_report and as a boolean in incremental. It's simpler to have less state and only carry it as an Option. ## Notes & open questions ## Change checklist - [x] Self-review. - ~~[ ] Documentation updates if relevant.~~ - ~~[ ] Tests if relevant.~~
1 parent b80b338 commit d22c1cd

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

iroh-net/src/netcheck/reportgen.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,12 @@ impl Client {
100100
let addr = Addr {
101101
sender: msg_tx.clone(),
102102
};
103-
let incremental = last_report.is_some();
104103
let mut actor = Actor {
105104
msg_tx,
106105
msg_rx,
107106
netcheck: netcheck.clone(),
108107
last_report,
109108
port_mapper,
110-
incremental,
111109
relay_map,
112110
stun_sock4,
113111
stun_sock6,
@@ -186,8 +184,6 @@ struct Actor {
186184
stun_sock6: Option<Arc<UdpSocket>>,
187185

188186
// Internal state.
189-
/// Whether we're doing an incremental report.
190-
incremental: bool,
191187
/// The report being built.
192188
report: Report,
193189
/// The hairping actor.
@@ -370,7 +366,7 @@ impl Actor {
370366
let enough_relays = std::cmp::min(self.relay_map.len(), ENOUGH_NODES);
371367
if self.report.relay_latency.len() == enough_relays {
372368
let timeout = self.report.relay_latency.max_latency();
373-
let timeout = match self.incremental {
369+
let timeout = match self.last_report.is_some() {
374370
true => timeout,
375371
false => timeout * 2,
376372
};
@@ -470,7 +466,7 @@ impl Actor {
470466
// If we're doing a full probe, also check for a captive portal. We
471467
// delay by a bit to wait for UDP STUN to finish, to avoid the probe if
472468
// it's unnecessary.
473-
if !self.incremental {
469+
if self.last_report.is_none() {
474470
// Even if we're doing a non-incremental update, we may want to try our
475471
// preferred relay for captive portal detection.
476472
let preferred_relay = self

0 commit comments

Comments
 (0)