Skip to content

Commit

Permalink
PIBD - Revert earlier pibd_aborted flag in sync logic (#3757)
Browse files Browse the repository at this point in the history
* revert earlier pibd_aborted flag in sync logic

* formatting
  • Loading branch information
yeastplume authored Jun 22, 2023
1 parent 45ebc8a commit 2273ea9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion servers/src/grin/sync/state_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct StateSync {
prev_state_sync: Option<DateTime<Utc>>,
state_sync_peer: Option<Arc<Peer>>,

pibd_aborted: bool,
earliest_zero_pibd_peer_time: Option<DateTime<Utc>>,
}

Expand All @@ -52,6 +53,7 @@ impl StateSync {
chain,
prev_state_sync: None,
state_sync_peer: None,
pibd_aborted: false,
earliest_zero_pibd_peer_time: None,
}
}
Expand All @@ -62,6 +64,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.
Expand Down Expand Up @@ -90,7 +98,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 {
Expand Down Expand Up @@ -315,6 +323,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 {
Expand Down

0 comments on commit 2273ea9

Please sign in to comment.