referrerpolicy=no-referrer-when-downgrade

Trait bp_relayers::StakeAndSlash

source ·
pub trait StakeAndSlash<AccountId, BlockNumber, Balance> {
    type RequiredStake: Get<Balance>;
    type RequiredRegistrationLease: Get<BlockNumber>;

    // Required methods
    fn reserve(relayer: &AccountId, amount: Balance) -> DispatchResult;
    fn unreserve(relayer: &AccountId, amount: Balance) -> Balance;
    fn repatriate_reserved<LaneId: Decode + Encode>(
        relayer: &AccountId,
        beneficiary: ExplicitOrAccountParams<AccountId, LaneId>,
        amount: Balance,
    ) -> Result<Balance, DispatchError>;
}
Expand description

Relayer stake-and-slash mechanism.

Required Associated Types§

source

type RequiredStake: Get<Balance>

The stake that the relayer must have to have its transactions boosted.

source

type RequiredRegistrationLease: Get<BlockNumber>

Required remaining registration lease to be able to get transaction priority boost.

If the difference between registration’s valid_till and the current block number is less than the RequiredRegistrationLease, it becomes inactive and relayer transaction won’t get priority boost. This period exists, because priority is calculated when transaction is placed to the queue (and it is reevaluated periodically) and then some time may pass before transaction will be included into the block.

Required Methods§

source

fn reserve(relayer: &AccountId, amount: Balance) -> DispatchResult

Reserve the given amount at relayer account.

source

fn unreserve(relayer: &AccountId, amount: Balance) -> Balance

Unreserve the given amount from relayer account.

Returns amount that we have failed to unreserve.

source

fn repatriate_reserved<LaneId: Decode + Encode>( relayer: &AccountId, beneficiary: ExplicitOrAccountParams<AccountId, LaneId>, amount: Balance, ) -> Result<Balance, DispatchError>

Slash up to amount from reserved balance of account relayer and send funds to given beneficiary.

Returns Ok(_) with non-zero balance if we have failed to repatriate some portion of stake.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<AccountId, BlockNumber, Balance> StakeAndSlash<AccountId, BlockNumber, Balance> for ()
where Balance: Default + Zero, BlockNumber: Default,

§

type RequiredStake = ()

§

type RequiredRegistrationLease = ()

source§

fn reserve(_relayer: &AccountId, _amount: Balance) -> DispatchResult

source§

fn unreserve(_relayer: &AccountId, _amount: Balance) -> Balance

source§

fn repatriate_reserved<LaneId: Decode + Encode>( _relayer: &AccountId, _beneficiary: ExplicitOrAccountParams<AccountId, LaneId>, _amount: Balance, ) -> Result<Balance, DispatchError>

Implementors§