From c370e174a413d285f9dc84274b9b8c9a4e4cc7f1 Mon Sep 17 00:00:00 2001 From: bayk Date: Fri, 21 Jun 2024 14:31:33 -0700 Subject: [PATCH] grin v5.3 (0122) PIBD - Revert earlier pibd_aborted flag in sync logic (#3757) * revert earlier pibd_aborted flag in sync logic * formatting --- servers/src/grin/sync/state_sync.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/servers/src/grin/sync/state_sync.rs b/servers/src/grin/sync/state_sync.rs index 7deaf17e7..c7f870e07 100644 --- a/servers/src/grin/sync/state_sync.rs +++ b/servers/src/grin/sync/state_sync.rs @@ -40,6 +40,7 @@ pub struct StateSync { last_logged_time: i64, last_download_size: u64, + pibd_aborted: bool, earliest_zero_pibd_peer_time: Option>, } @@ -57,6 +58,7 @@ impl StateSync { state_sync_peer: None, last_logged_time: 0, last_download_size: 0, + pibd_aborted: false, earliest_zero_pibd_peer_time: None, } } @@ -67,6 +69,12 @@ impl StateSync { self.earliest_zero_pibd_peer_time = t; } + /// Flag to abort PIBD process within StateSync, intentionally separate from `sync_state`, + /// which can be reset between calls + pub fn set_pibd_aborted(&mut self) { + self.pibd_aborted = true; + } + /// Check whether state sync should run and triggers a state download when /// it's time (we have all headers). Returns true as long as state sync /// needs monitoring, false when it's either done or turned off. @@ -95,7 +103,7 @@ impl StateSync { let using_pibd = !matches!( self.sync_state.status(), SyncStatus::TxHashsetPibd { aborted: true, .. }, - ); + ) && !self.pibd_aborted; // Check whether we've errored and should restart pibd if using_pibd { @@ -320,6 +328,7 @@ impl StateSync { .update_pibd_progress(true, true, 0, 1, &archive_header); self.sync_state .set_sync_error(chain::Error::AbortingPIBDError); + self.set_pibd_aborted(); return false; } } else {