Skip to content

Commit

Permalink
impl of calculate_fee_by_gas_usage method in GasPrice struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
NirLevi-starkware committed Jun 12, 2023
1 parent a891109 commit 71ad00e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::core::{ContractAddress, GlobalRoot};
use crate::hash::StarkHash;
use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex};
use crate::transaction::{Transaction, TransactionOutput};
use crate::transaction::{Fee, Transaction, TransactionOutput};

/// A block.
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
Expand Down Expand Up @@ -128,6 +128,12 @@ impl From<GasPrice> for PrefixedBytesAsHex<16_usize> {
}
}

impl GasPrice {
pub fn calculate_fee_by_gas_usage(&self, gas_usage: f64) -> Fee {
Fee((gas_usage.ceil() as u128) * self.0)
}
}

/// The timestamp of a [Block](`crate::block::Block`).
#[derive(
Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord,
Expand Down

0 comments on commit 71ad00e

Please sign in to comment.