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§
sourcetype RequiredStake: Get<Balance>
type RequiredStake: Get<Balance>
The stake that the relayer must have to have its transactions boosted.
sourcetype RequiredRegistrationLease: Get<BlockNumber>
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§
sourcefn reserve(relayer: &AccountId, amount: Balance) -> DispatchResult
fn reserve(relayer: &AccountId, amount: Balance) -> DispatchResult
Reserve the given amount at relayer account.
sourcefn unreserve(relayer: &AccountId, amount: Balance) -> Balance
fn unreserve(relayer: &AccountId, amount: Balance) -> Balance
Unreserve
the given amount from relayer account.
Returns amount that we have failed to unreserve
.
sourcefn repatriate_reserved<LaneId: Decode + Encode>(
relayer: &AccountId,
beneficiary: ExplicitOrAccountParams<AccountId, LaneId>,
amount: Balance,
) -> Result<Balance, DispatchError>
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.