Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIBD - Revert earlier pibd_aborted flag in sync logic #3757

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abort_pid() seems like a more straightforward name

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