mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Implement "Add BlockBody::transaction_count helper function" (#13660)
This commit is contained in:
@ -232,6 +232,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<H, B> SealedBlock<H, B>
|
||||
where
|
||||
B: reth_primitives_traits::BlockBody,
|
||||
{
|
||||
/// Returns the number of transactions in the block.
|
||||
#[inline]
|
||||
pub fn transaction_count(&self) -> usize {
|
||||
self.body.transaction_count()
|
||||
}
|
||||
}
|
||||
|
||||
impl<H, B> SealedBlock<H, B>
|
||||
where
|
||||
H: alloy_consensus::BlockHeader,
|
||||
@ -918,4 +929,14 @@ mod tests {
|
||||
let decoded = BlockBody::decode(&mut buf.as_slice()).unwrap();
|
||||
assert_eq!(body, decoded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transaction_count() {
|
||||
let mut block = Block::default();
|
||||
assert_eq!(block.body.transaction_count(), 0);
|
||||
block.body.transactions.push(TransactionSigned::default());
|
||||
assert_eq!(block.body.transaction_count(), 1);
|
||||
block.body.transactions.push(TransactionSigned::default());
|
||||
assert_eq!(block.body.transaction_count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user