pub struct FeeRate { /* private fields */ }Expand description
A struct containing a fee rate.
The fee rate is defined as a per-weight cost, along with a mask for rounding purposes.
Implementations§
Source§impl FeeRate
impl FeeRate
Sourcepub fn new(per_weight: u64, mask: u64) -> Option<FeeRate>
pub fn new(per_weight: u64, mask: u64) -> Option<FeeRate>
Construct a new fee rate.
Returns None if the fee rate is invalid.
Sourcepub fn write(&self, w: &mut impl Write) -> Result<()>
pub fn write(&self, w: &mut impl Write) -> Result<()>
Write the FeeRate.
This is not a Monero protocol defined struct, and this is accordingly not a Monero protocol defined serialization. This may run in time variable to its value.
Sourcepub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serialize the FeeRate to a Vec<u8>.
This is not a Monero protocol defined struct, and this is accordingly not a Monero protocol defined serialization. This may run in time variable to its value.
Sourcepub fn per_weight(&self) -> u64
pub fn per_weight(&self) -> u64
The fee to pay per weight.
Sourcepub fn read(r: &mut impl Read) -> Result<FeeRate>
pub fn read(r: &mut impl Read) -> Result<FeeRate>
Read a FeeRate.
This is not a Monero protocol defined struct, and this is accordingly not a Monero protocol defined serialization. This may run in time variable to its value.
Sourcepub fn calculate_fee_from_weight(&self, weight: usize) -> u64
pub fn calculate_fee_from_weight(&self, weight: usize) -> u64
Calculate the fee to use from the weight.
This function may panic upon overflow.
Sourcepub fn calculate_weight_from_fee(&self, fee: u64) -> Option<usize>
pub fn calculate_weight_from_fee(&self, fee: u64) -> Option<usize>
Calculate the weight from the fee.
Returns None if the weight would not fit within a usize.