Skip to content

Commit ab2e851

Browse files
authored
refactor: replace SyncPhase matches wildcard usage with exhaustive match (#239)
1 parent 8009033 commit ab2e851

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

dash-spv/src/sync/phase_execution.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ impl<
185185
self.transition_to_next_phase(storage, network, "No blocks to download").await?;
186186
}
187187

188-
_ => {
189-
// Idle or FullySynced - nothing to execute
188+
SyncPhase::Idle
189+
| SyncPhase::FullySynced {
190+
..
191+
} => {
192+
// Nothing to execute
190193
}
191194
}
192195

@@ -422,7 +425,15 @@ impl<
422425
}
423426
}
424427
}
425-
_ => {}
428+
SyncPhase::Idle
429+
| SyncPhase::FullySynced {
430+
..
431+
}
432+
| SyncPhase::DownloadingBlocks {
433+
..
434+
} => {
435+
// Nothing to execute
436+
}
426437
}
427438

428439
Ok(())
@@ -467,7 +478,16 @@ impl<
467478
} => {
468479
self.filter_sync.check_cfheader_request_timeouts(network, storage).await?;
469480
}
470-
_ => {
481+
SyncPhase::Idle
482+
| SyncPhase::DownloadingFilters {
483+
..
484+
}
485+
| SyncPhase::DownloadingBlocks {
486+
..
487+
}
488+
| SyncPhase::FullySynced {
489+
..
490+
} => {
471491
// For other phases, we'll need phase-specific recovery
472492
}
473493
}

dash-spv/src/sync/phases.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ impl SyncPhase {
170170
last_progress,
171171
..
172172
} => Some(*last_progress),
173-
_ => None,
173+
SyncPhase::Idle
174+
| SyncPhase::FullySynced {
175+
..
176+
} => None,
174177
}
175178
}
176179

@@ -198,7 +201,10 @@ impl SyncPhase {
198201
last_progress,
199202
..
200203
} => *last_progress = now,
201-
_ => {}
204+
SyncPhase::Idle
205+
| SyncPhase::FullySynced {
206+
..
207+
} => {}
202208
}
203209
}
204210
}
@@ -421,7 +427,10 @@ impl SyncPhase {
421427
}
422428
}
423429

424-
_ => PhaseProgress {
430+
SyncPhase::Idle
431+
| SyncPhase::FullySynced {
432+
..
433+
} => PhaseProgress {
425434
phase_name: self.name(),
426435
items_completed: 0,
427436
items_total: None,

0 commit comments

Comments
 (0)