mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
PIBD - Revert earlier pibd_aborted flag in sync logic (#3757)
* revert earlier pibd_aborted flag in sync logic * formatting
This commit is contained in:
parent
45ebc8ae50
commit
2273ea986d
1 changed files with 10 additions and 1 deletions
|
@ -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>>,
|
||||
}
|
||||
|
||||
|
@ -52,6 +53,7 @@ impl StateSync {
|
|||
chain,
|
||||
prev_state_sync: None,
|
||||
state_sync_peer: None,
|
||||
pibd_aborted: false,
|
||||
earliest_zero_pibd_peer_time: None,
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue