feat: add blob costs to cost value (#4489)

This commit is contained in:
Matthias Seitz
2023-09-05 21:12:42 +02:00
committed by GitHub
parent 01d4933125
commit ca3753d53f
2 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,5 @@
use crate::{
compression::{TRANSACTION_COMPRESSOR, TRANSACTION_DECOMPRESSOR},
constants::eip4844::DATA_GAS_PER_BLOB,
keccak256, Address, Bytes, TxHash, H256,
};
pub use access_list::{AccessList, AccessListItem, AccessListWithGasUsed};
@ -236,10 +235,10 @@ impl Transaction {
/// Returns the blob gas used for all blobs of the EIP-4844 transaction if it is an EIP-4844
/// transaction.
///
/// This is the number of blobs times the [DATA_GAS_PER_BLOB] a single blob consumes.
pub fn blob_gas_used(&self) -> Option<u128> {
let tx = self.as_eip4844()?;
Some(tx.blob_versioned_hashes.len() as u128 * DATA_GAS_PER_BLOB as u128)
/// This is the number of blobs times the
/// [DATA_GAS_PER_BLOB](crate::constants::eip4844::DATA_GAS_PER_BLOB) a single blob consumes.
pub fn blob_gas_used(&self) -> Option<u64> {
self.as_eip4844().map(TxEip4844::blob_gas)
}
/// Return the max priority fee per gas if the transaction is an EIP-1559 transaction, and