Skip to content

Commit

Permalink
add docs for get_block_gas_details and fix nit for panic
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaVashchuk committed Aug 6, 2024
1 parent 85b4e8f commit 9cb5a85
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,17 +645,26 @@ impl ForkDetails {
);
}

/// Returns
///
/// - `l1_gas_price`
/// - `l2_fair_gas_price`
/// - `fair_pubdata_price`
///
/// for the given l2 block.
pub fn get_block_gas_details(&self, miniblock: u32) -> Option<(u64, u64, u64)> {
let res_opt_block_details = self.fork_source.get_block_details(L2BlockNumber(miniblock));
match res_opt_block_details {
Ok(opt_block_details) => opt_block_details.map(|block_details| {
(
block_details.base.l1_gas_price,
block_details.base.l2_fair_gas_price,
block_details
.base
.fair_pubdata_price
.expect("fair pubdata price is not present in block details"),
block_details.base.fair_pubdata_price.unwrap_or_else(|| {
panic!(
"fair pubdata price is not present in {} l2 block details",
miniblock
)
}),
)
}),
Err(e) => {
Expand Down

0 comments on commit 9cb5a85

Please sign in to comment.