Skip to content

Commit

Permalink
grin v5.3 (0122) PIBD - Revert earlier pibd_aborted flag in sync logic (
Browse files Browse the repository at this point in the history
mimblewimble#3757)

* revert earlier pibd_aborted flag in sync logic
* formatting
  • Loading branch information
bayk committed Jun 21, 2024
1 parent c0d67ba commit c370e17
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 @@ -40,6 +40,7 @@ pub struct StateSync {
last_logged_time: i64,
last_download_size: u64,

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

Expand All @@ -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,
}
}
Expand All @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c370e17

Please sign in to comment.