fix: mark downloaded block as invalid if insertion fails (#3003)

This commit is contained in:
Dan Cline
2023-06-05 20:13:54 -04:00
committed by GitHub
parent 088c388d13
commit 9614b4667c
2 changed files with 10 additions and 0 deletions

View File

@ -1009,6 +1009,10 @@ where
}
Err(err) => {
debug!(target: "consensus::engine", ?err, "Failed to insert downloaded block");
if !matches!(err.kind(), InsertBlockErrorKind::Internal(_)) {
// non-internal error kinds occurr if the payload is invalid
self.invalid_headers.insert(err.into_block().header);
}
}
}
}

View File

@ -65,6 +65,12 @@ impl InsertBlockError {
Self::new(block, InsertBlockErrorKind::Execution(error))
}
/// Consumes the error and returns the block that resulted in the error
#[inline]
pub fn into_block(self) -> SealedBlock {
self.inner.block
}
/// Returns the error kind
#[inline]
pub fn kind(&self) -> &InsertBlockErrorKind {