Trait polkadot_runtime_common::traits::Leaser [−][src]
pub trait Leaser<BlockNumber> {
type AccountId;
type LeasePeriod;
type Currency: ReservableCurrency<Self::AccountId>;
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_length() -> (BlockNumber, BlockNumber);
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.
Associated Types
type LeasePeriod
type LeasePeriod
The measurement type for counting lease periods (generally just a BlockNumber
).
type Currency: ReservableCurrency<Self::AccountId>
type Currency: ReservableCurrency<Self::AccountId>
The currency type in which the lease is taken.
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 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.
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.
fn lease_period_length() -> (BlockNumber, BlockNumber)
fn lease_period_length() -> (BlockNumber, BlockNumber)
The length of a lease period, and any offset which may be introduced. This is only used in benchmarking to automate certain calls.
fn lease_period_index(block: BlockNumber) -> Option<(Self::LeasePeriod, bool)>
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.
fn already_leased(
para_id: ParaId,
first_period: Self::LeasePeriod,
last_period: Self::LeasePeriod
) -> bool
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
..] .