fix(consensus-engine): handle pipeline unwind (#1938)

This commit is contained in:
Roman Krasiuk
2023-03-23 23:13:58 +02:00
committed by GitHub
parent 1ce021f250
commit 95815c7e99
2 changed files with 15 additions and 6 deletions

View File

@@ -321,12 +321,17 @@ where
}
match result {
Ok(_) => {
// Terminate the sync early if it's reached the maximum user
// configured block.
let minimum_pipeline_progress = *pipeline.minimum_progress();
if this.has_reached_max_block(minimum_pipeline_progress) {
return Poll::Ready(Ok(()))
Ok(ctrl) => {
if ctrl.is_unwind() {
this.require_pipeline_run(PipelineTarget::Head);
} else {
// Terminate the sync early if it's reached the maximum user
// configured block.
let minimum_pipeline_progress =
*pipeline.minimum_progress();
if this.has_reached_max_block(minimum_pipeline_progress) {
return Poll::Ready(Ok(()))
}
}
}
// Any pipeline error at this point is fatal.

View File

@@ -25,4 +25,8 @@ impl ControlFlow {
pub fn should_continue(&self) -> bool {
matches!(self, ControlFlow::Continue { .. } | ControlFlow::NoProgress { .. })
}
pub fn is_unwind(&self) -> bool {
matches!(self, ControlFlow::Unwind { .. })
}
}