mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: crates/consensus - Use derive_more::Error rather than impl std:error:Error (#10831)
Co-authored-by: garwah <garwah@garwah>
This commit is contained in:
@ -127,7 +127,7 @@ pub trait Consensus: Debug + Send + Sync {
|
||||
}
|
||||
|
||||
/// Consensus Errors
|
||||
#[derive(Debug, PartialEq, Eq, Clone, derive_more::Display)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, derive_more::Display, derive_more::Error)]
|
||||
pub enum ConsensusError {
|
||||
/// Error when the gas used in the header exceeds the gas limit.
|
||||
#[display("block used gas ({gas_used}) is greater than gas limit ({gas_limit})")]
|
||||
@ -395,16 +395,6 @@ pub enum ConsensusError {
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for ConsensusError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Self::InvalidTransaction(err) => std::error::Error::source(err),
|
||||
_ => Option::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ConsensusError {
|
||||
/// Returns `true` if the error is a state root error.
|
||||
pub const fn is_state_root_error(&self) -> bool {
|
||||
@ -419,9 +409,6 @@ impl From<InvalidTransactionError> for ConsensusError {
|
||||
}
|
||||
|
||||
/// `HeaderConsensusError` combines a `ConsensusError` with the `SealedHeader` it relates to.
|
||||
#[derive(derive_more::Display, Debug)]
|
||||
#[derive(derive_more::Display, derive_more::Error, Debug)]
|
||||
#[display("Consensus error: {_0}, Invalid header: {_1:?}")]
|
||||
pub struct HeaderConsensusError(ConsensusError, SealedHeader);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for HeaderConsensusError {}
|
||||
|
||||
Reference in New Issue
Block a user