mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: merge BlockBodyTxExt trait into BlockBody (#13613)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
traits::BlockExt, transaction::SignedTransactionIntoRecoveredExt, BlockBodyTxExt, GotExpected,
|
||||
RecoveredTx, SealedHeader, TransactionSigned,
|
||||
traits::BlockExt, transaction::SignedTransactionIntoRecoveredExt, GotExpected, RecoveredTx,
|
||||
SealedHeader, TransactionSigned,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::Header;
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
transaction::{recover_signers, recover_signers_unchecked},
|
||||
BlockWithSenders, SealedBlock,
|
||||
};
|
||||
use crate::{BlockWithSenders, SealedBlock};
|
||||
use alloc::vec::Vec;
|
||||
use reth_primitives_traits::{Block, BlockBody, SealedHeader, SignedTransaction};
|
||||
use revm_primitives::{Address, B256};
|
||||
@ -52,7 +49,6 @@ pub trait BlockExt: Block {
|
||||
///
|
||||
/// If the number of senders does not match the number of transactions in the block, this falls
|
||||
/// back to manually recovery, but _without ensuring that the signature has a low `s` value_.
|
||||
/// See also [`recover_signers_unchecked`]
|
||||
///
|
||||
/// Returns an error if a signature is invalid.
|
||||
#[track_caller]
|
||||
@ -87,28 +83,3 @@ pub trait BlockExt: Block {
|
||||
}
|
||||
|
||||
impl<T: Block> BlockExt for T {}
|
||||
|
||||
/// Extension trait for [`BlockBody`] adding helper methods operating with transactions.
|
||||
pub trait BlockBodyTxExt: BlockBody {
|
||||
/// Recover signer addresses for all transactions in the block body.
|
||||
fn recover_signers(&self) -> Option<Vec<Address>>
|
||||
where
|
||||
Self::Transaction: SignedTransaction,
|
||||
{
|
||||
recover_signers(self.transactions(), self.transactions().len())
|
||||
}
|
||||
|
||||
/// Recover signer addresses for all transactions in the block body _without ensuring that the
|
||||
/// signature has a low `s` value_.
|
||||
///
|
||||
/// Returns `None`, if some transaction's signature is invalid, see also
|
||||
/// [`recover_signers_unchecked`].
|
||||
fn recover_signers_unchecked(&self) -> Option<Vec<Address>>
|
||||
where
|
||||
Self::Transaction: SignedTransaction,
|
||||
{
|
||||
recover_signers_unchecked(self.transactions(), self.transactions().len())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: BlockBody> BlockBodyTxExt for T {}
|
||||
|
||||
Reference in New Issue
Block a user