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§
Sourceconst MIN_FEE_FACTOR: FixedU128 = _
const MIN_FEE_FACTOR: FixedU128 = _
Minimal delivery fee factor.
Sourceconst EXPONENTIAL_FEE_BASE: FixedU128 = _
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.
Sourceconst MESSAGE_SIZE_FEE_BASE: FixedU128 = _
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§
Required Methods§
Sourcefn get_fee_factor(id: Self::Id) -> FixedU128
fn get_fee_factor(id: Self::Id) -> FixedU128
Returns the current message fee factor.
Sourcefn set_fee_factor(id: Self::Id, val: FixedU128)
fn set_fee_factor(id: Self::Id, val: FixedU128)
Sets the current message fee factor.
Provided Methods§
fn do_increase_fee_factor(fee_factor: &mut FixedU128, message_size: u128)
Sourcefn increase_fee_factor(id: Self::Id, message_size: u128)
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.
fn do_decrease_fee_factor(fee_factor: &mut FixedU128) -> bool
Sourcefn decrease_fee_factor(id: Self::Id) -> bool
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.