mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(sync): add block number to body validation error (#7918)
Co-authored-by: Oliver Nordbjerg <onbjerg@users.noreply.github.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -158,10 +158,12 @@ pub enum DownloadError {
|
||||
|
||||
/* ==================== BODIES ERRORS ==================== */
|
||||
/// Block validation failed
|
||||
#[error("failed to validate body for header {hash}: {error}")]
|
||||
#[error("failed to validate body for header {hash}, block number {number}: {error}")]
|
||||
BodyValidation {
|
||||
/// Hash of header failing validation
|
||||
/// Hash of the block failing validation
|
||||
hash: B256,
|
||||
/// Number of the block failing validation
|
||||
number: u64,
|
||||
/// The details of validation failure
|
||||
#[source]
|
||||
error: Box<ConsensusError>,
|
||||
|
||||
@ -184,8 +184,13 @@ where
|
||||
if let Err(error) = self.consensus.validate_block(&block) {
|
||||
// Body is invalid, put the header back and return an error
|
||||
let hash = block.hash();
|
||||
let number = block.number;
|
||||
self.pending_headers.push_front(block.header);
|
||||
return Err(DownloadError::BodyValidation { hash, error: Box::new(error) })
|
||||
return Err(DownloadError::BodyValidation {
|
||||
hash,
|
||||
number,
|
||||
error: Box::new(error),
|
||||
})
|
||||
}
|
||||
|
||||
self.buffer.push(BlockResponse::Full(block));
|
||||
|
||||
Reference in New Issue
Block a user