use crate::{
consensus::{self, BlockHeight},
transaction::components::{
amount::{Amount, DEFAULT_FEE},
transparent::fees as transparent,
},
};
#[cfg(feature = "zfuture")]
use crate::transaction::components::tze::fees as tze;
#[derive(Clone, Copy, Debug)]
pub struct FeeRule {
fixed_fee: Amount,
}
impl FeeRule {
pub fn non_standard(fixed_fee: Amount) -> Self {
Self { fixed_fee }
}
pub fn standard() -> Self {
Self {
fixed_fee: DEFAULT_FEE,
}
}
pub fn fixed_fee(&self) -> Amount {
self.fixed_fee
}
}
impl super::FeeRule for FeeRule {
type Error = std::convert::Infallible;
fn fee_required<P: consensus::Parameters>(
&self,
_params: &P,
_target_height: BlockHeight,
_transparent_inputs: &[impl transparent::InputView],
_transparent_outputs: &[impl transparent::OutputView],
_sapling_input_count: usize,
_sapling_output_count: usize,
) -> Result<Amount, Self::Error> {
Ok(self.fixed_fee)
}
}
#[cfg(feature = "zfuture")]
impl super::FutureFeeRule for FeeRule {
fn fee_required_zfuture<P: consensus::Parameters>(
&self,
_params: &P,
_target_height: BlockHeight,
_transparent_inputs: &[impl transparent::InputView],
_transparent_outputs: &[impl transparent::OutputView],
_sapling_input_count: usize,
_sapling_output_count: usize,
_tze_inputs: &[impl tze::InputView],
_tze_outputs: &[impl tze::OutputView],
) -> Result<Amount, Self::Error> {
Ok(self.fixed_fee)
}
}