mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: move gas_spent_by_transactions to traits (#12541)
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
//! Receipt abstraction
|
||||
|
||||
use core::fmt;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::TxReceipt;
|
||||
use alloy_primitives::B256;
|
||||
use core::fmt;
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -32,3 +32,16 @@ pub trait Receipt:
|
||||
/// Calculates the receipts root of the given receipts.
|
||||
fn receipts_root(receipts: &[&Self]) -> B256;
|
||||
}
|
||||
|
||||
/// Retrieves gas spent by transactions as a vector of tuples (transaction index, gas used).
|
||||
pub fn gas_spent_by_transactions<I, T>(receipts: I) -> Vec<(u64, u64)>
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: TxReceipt,
|
||||
{
|
||||
receipts
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(id, receipt)| (id as u64, receipt.cumulative_gas_used() as u64))
|
||||
.collect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user