feat(primitives): add calculate_blob_gas_used function in SealedBlock (#4692)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Thomas Coratger
2023-09-20 23:34:07 +02:00
committed by GitHub
parent 0874767cd9
commit 1962014a77
2 changed files with 6 additions and 2 deletions

View File

@ -203,6 +203,11 @@ impl SealedBlock {
self.ommers.iter().map(Header::size).sum::<usize>() + self.ommers.capacity() * std::mem::size_of::<Header>() +
self.withdrawals.as_ref().map(|w| w.iter().map(Withdrawal::size).sum::<usize>() + w.capacity() * std::mem::size_of::<Withdrawal>()).unwrap_or(std::mem::size_of::<Option<Vec<Withdrawal>>>())
}
/// Calculates the total gas used by blob transactions in the sealed block.
pub fn blob_gas_used(&self) -> u64 {
self.blob_transactions().iter().filter_map(|tx| tx.blob_gas_used()).sum()
}
}
impl From<SealedBlock> for Block {