Substrate的transaction-payment模块分

2019-11-28  本文已影响0人  建怀

Substrate的transaction-payment模块分析

transaction-payment模块提供了转账包括的最小数量的手续费收取逻辑。

额外,还可以允许去配置如下:

Trait

/// The currency type in which fees will be paid.
type Currency: Currency<Self::AccountId>;

/// Handler for the unbalanced reduction when taking transaction fees.
type OnTransactionPayment: OnUnbalanced<NegativeImbalanceOf<Self>>;

/// The fee to be paid for making a transaction; the base.
type TransactionBaseFee: Get<BalanceOf<Self>>;

/// The fee to be paid for making a transaction; the per-byte portion.
type TransactionByteFee: Get<BalanceOf<Self>>;

/// Convert a weight value into a deductible fee based on the currency type.
type WeightToFee: Convert<Weight, BalanceOf<Self>>;

/// Update the multiplier of the next block, based on the previous block's weight.
type FeeMultiplierUpdate: Convert<Multiplier, Multiplier>;

Store

NextFeeMultiplier get(fn next_fee_multiplier): Multiplier = Multiplier::from_parts(0);

Module

fn on_finalize() {
    NextFeeMultiplier::mutate(|fm| {
        *fm = T::FeeMultiplierUpdate::convert(*fm)
    });
}

ChargeTransactionPayment

pub struct ChargeTransactionPayment<T: Trait + Send + Sync>(#[codec(compact)] BalanceOf<T>);
上一篇 下一篇

猜你喜欢

热点阅读