pub trait Leaser<BlockNumber> {
    type AccountId;
    type LeasePeriod;
    type Currency: ReservableCurrency<Self::AccountId>;

    // Required methods
    fn lease_out(
        para: ParaId,
        leaser: &Self::AccountId,
        amount: <Self::Currency as Currency<Self::AccountId>>::Balance,
        period_begin: Self::LeasePeriod,
        period_count: Self::LeasePeriod
    ) -> Result<(), LeaseError>;
    fn deposit_held(
        para: ParaId,
        leaser: &Self::AccountId
    ) -> <Self::Currency as Currency<Self::AccountId>>::Balance;
    fn lease_period_index(
        block: BlockNumber
    ) -> Option<(Self::LeasePeriod, bool)>;
    fn already_leased(
        para_id: ParaId,
        first_period: Self::LeasePeriod,
        last_period: Self::LeasePeriod
    ) -> bool;
}
Expand description

Lease manager. Used by the auction module to handle parachain slot leases.

Required Associated Types§

source

type AccountId

An account identifier for a leaser.

source

type LeasePeriod

The measurement type for counting lease periods (generally just a BlockNumber).

source

type Currency: ReservableCurrency<Self::AccountId>

The currency type in which the lease is taken.

Required Methods§

source

fn lease_out( para: ParaId, leaser: &Self::AccountId, amount: <Self::Currency as Currency<Self::AccountId>>::Balance, period_begin: Self::LeasePeriod, period_count: Self::LeasePeriod ) -> Result<(), LeaseError>

Lease a new parachain slot for para.

leaser shall have a total of amount balance reserved by the implementer of this trait.

Note: The implementer of the trait (the leasing system) is expected to do all reserve/unreserve calls. The caller of this trait SHOULD NOT pre-reserve the deposit (though should ensure that it is reservable).

The lease will last from period_begin for period_count lease periods. It is undefined if the para already has a slot leased during those periods.

Returns Err in the case of an error, and in which case nothing is changed.

source

fn deposit_held( para: ParaId, leaser: &Self::AccountId ) -> <Self::Currency as Currency<Self::AccountId>>::Balance

Return the amount of balance currently held in reserve on leaser’s account for leasing para. This won’t go down outside a lease period.

source

fn lease_period_index(block: BlockNumber) -> Option<(Self::LeasePeriod, bool)>

Returns the lease period at block, and if this is the first block of a new lease period.

Will return None if the first lease period has not started yet, for example when an offset is placed.

source

fn already_leased( para_id: ParaId, first_period: Self::LeasePeriod, last_period: Self::LeasePeriod ) -> bool

Returns true if the parachain already has a lease in any of lease periods in the inclusive range [first_period, last_period], intersected with the unbounded range [current_lease_period..] .

Implementors§

source§

impl<T: Config> Leaser<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>

§

type AccountId = <T as Config>::AccountId

§

type LeasePeriod = <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number

§

type Currency = <T as Config>::Currency