referrerpolicy=no-referrer-when-downgrade

Trait FeeTracker

Source
pub trait FeeTracker {
    type Id: Copy;

    const MIN_FEE_FACTOR: FixedU128 = _;
    const EXPONENTIAL_FEE_BASE: FixedU128 = _;
    const MESSAGE_SIZE_FEE_BASE: FixedU128 = _;

    // Required methods
    fn get_fee_factor(id: Self::Id) -> FixedU128;
    fn set_fee_factor(id: Self::Id, val: FixedU128);

    // Provided methods
    fn do_increase_fee_factor(fee_factor: &mut FixedU128, message_size: u128) { ... }
    fn increase_fee_factor(id: Self::Id, message_size: u128) { ... }
    fn do_decrease_fee_factor(fee_factor: &mut FixedU128) -> bool { ... }
    fn decrease_fee_factor(id: Self::Id) -> bool { ... }
}
Expand description

Trait for tracking message delivery fees on a transport protocol.

Provided Associated Constants§

Source

const MIN_FEE_FACTOR: FixedU128 = _

Minimal delivery fee factor.

Source

const EXPONENTIAL_FEE_BASE: FixedU128 = _

The factor that is used to increase the current message fee factor when the transport protocol is experiencing some lags.

Source

const MESSAGE_SIZE_FEE_BASE: FixedU128 = _

The factor that is used to increase the current message fee factor for every sent kilobyte.

Required Associated Types§

Source

type Id: Copy

Type used for assigning different fee factors to different destinations

Required Methods§

Source

fn get_fee_factor(id: Self::Id) -> FixedU128

Returns the current message fee factor.

Source

fn set_fee_factor(id: Self::Id, val: FixedU128)

Sets the current message fee factor.

Provided Methods§

Source

fn do_increase_fee_factor(fee_factor: &mut FixedU128, message_size: u128)

Source

fn increase_fee_factor(id: Self::Id, message_size: u128)

Increases the delivery fee factor by a factor based on message size and records the result.

Source

fn do_decrease_fee_factor(fee_factor: &mut FixedU128) -> bool

Source

fn decrease_fee_factor(id: Self::Id) -> bool

Decreases the delivery fee factor by a constant factor and records the result.

Does not reduce the fee factor below the initial value, which is currently set as 1.

Returns true if the fee factor was actually decreased, false otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Config> FeeTracker for Pallet<T>

Source§

type Id = Id