mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add PayloadError to PayloadStatus conversion (#2123)
This commit is contained in:
@ -294,9 +294,7 @@ where
|
||||
Ok(block) => block,
|
||||
Err(error) => {
|
||||
error!(target: "consensus::engine", ?block_hash, block_number, ?error, "Invalid payload");
|
||||
return Ok(PayloadStatus::from_status(PayloadStatusEnum::InvalidBlockHash {
|
||||
validation_error: error.to_string(),
|
||||
}))
|
||||
return Ok(error.into())
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ pub enum PayloadError {
|
||||
#[error("Invalid payload base fee: {0}")]
|
||||
BaseFee(U256),
|
||||
/// Invalid payload block hash.
|
||||
#[error("Invalid payload block hash. Execution: {execution}. Consensus: {consensus}")]
|
||||
#[error("blockhash mismatch, want {consensus}, got {execution}")]
|
||||
BlockHash {
|
||||
/// The block hash computed from the payload.
|
||||
execution: H256,
|
||||
@ -283,6 +283,21 @@ impl Serialize for PayloadStatus {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PayloadError> for PayloadStatus {
|
||||
fn from(error: PayloadError) -> Self {
|
||||
match error {
|
||||
error @ PayloadError::BlockHash { .. } => {
|
||||
PayloadStatus::from_status(PayloadStatusEnum::InvalidBlockHash {
|
||||
validation_error: error.to_string(),
|
||||
})
|
||||
}
|
||||
_ => PayloadStatus::from_status(PayloadStatusEnum::Invalid {
|
||||
validation_error: error.to_string(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "status", rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum PayloadStatusEnum {
|
||||
|
||||
Reference in New Issue
Block a user