refactor: use BlockWithSenders in executors (#5771)

This commit is contained in:
Bjerg
2023-12-15 14:57:41 +02:00
committed by GitHub
parent 1eaa3ed5a5
commit faa9a22a71
12 changed files with 183 additions and 186 deletions

View File

@ -53,6 +53,11 @@ impl Block {
}
}
/// Expensive operation that recovers transaction signer. See [SealedBlockWithSenders].
pub fn senders(&self) -> Option<Vec<Address>> {
TransactionSigned::recover_signers(&self.body, self.body.len())
}
/// Transform into a [`BlockWithSenders`].
///
/// # Panics
@ -71,6 +76,15 @@ impl Block {
BlockWithSenders { block: self, senders }
}
/// **Expensive**. Transform into a [`BlockWithSenders`] by recovering senders in the contained
/// transactions.
///
/// Returns `None` if a transaction is invalid.
pub fn with_recovered_senders(self) -> Option<BlockWithSenders> {
let senders = self.senders()?;
Some(BlockWithSenders { block: self, senders })
}
/// Returns whether or not the block contains any blob transactions.
pub fn has_blob_transactions(&self) -> bool {
self.body.iter().any(|tx| tx.is_eip4844())