Skip to content

Commit

Permalink
feat: introduce maybe helpers for blob calc (#1962)
Browse files Browse the repository at this point in the history
* feat: introduce maybe helpers for blob calc

* feat: introduce maybe helpers for blob calc
  • Loading branch information
mattsse authored Jan 29, 2025
1 parent 2c95b2f commit 83d7270
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/consensus/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,14 @@ pub trait BlockHeader {
Some(blob_params.next_block_excess_blob_gas(self.excess_blob_gas()?, self.blob_gas_used()?))
}

/// Convenience function for [`Self::next_block_excess_blob_gas`] with an optional
/// [`BlobParams`] argument.
///
/// Returns `None` if the `blob_params` are `None`.
fn maybe_next_block_excess_blob_gas(&self, blob_params: Option<BlobParams>) -> Option<u64> {
self.next_block_excess_blob_gas(blob_params?)
}

/// Returns the blob fee for the next block according to the EIP-4844 spec.
///
/// Returns `None` if `excess_blob_gas` is None.
Expand All @@ -648,6 +656,14 @@ pub trait BlockHeader {
Some(blob_params.calc_blob_fee(self.next_block_excess_blob_gas(blob_params)?))
}

/// Convenience function for [`Self::next_block_blob_fee`] with an optional [`BlobParams`]
/// argument.
///
/// Returns `None` if the `blob_params` are `None`.
fn maybe_next_block_blob_fee(&self, blob_params: Option<BlobParams>) -> Option<u128> {
self.next_block_blob_fee(blob_params?)
}

/// Calculate base fee for next block according to the EIP-1559 spec.
///
/// Returns a `None` if no base fee is set, no EIP-1559 support
Expand Down

0 comments on commit 83d7270

Please sign in to comment.