Expand description
Slots functionality for Substrate.
Some consensus algorithms have a concept of slots, which are intervals in time during which certain events can and/or must occur. This crate provides generic functionality for slots.
Structs§
- Backoff
Authoring OnFinalized Head Lagging - A simple default strategy for how to decide backing off authoring blocks if the number of unfinalized blocks grows too large.
- Simple
Slot Worker ToSlot Worker - A type that implements
SlotWorker
for a type that implementsSimpleSlotWorker
. - Slot
Info - Information about a slot.
- Slot
Proportion - A unit type wrapper to express the proportion of a slot.
- Slot
Result - The result of
SlotWorker::on_slot
.
Enums§
- Checked
Header - A header which has been checked
- Slot
Lenience Type - The strategy used to calculate the slot lenience used to increase the block proposal time when slots have been skipped with no blocks authored.
Constants§
- MAX_
SLOT_ CAPACITY - We keep at least this number of slots in database.
- PRUNING_
BOUND - We prune slots when they reach this number.
Traits§
- Backoff
Authoring Blocks Strategy - Trait for providing the strategy for when to backoff block authoring.
- Inherent
Data Provider Ext - Slot specific extension that the inherent data provider needs to implement.
- Simple
Slot Worker - A skeleton implementation for
SlotWorker
which tries to claim a slot at its beginning and tries to produce a block if successfully claimed, timing out if block production takes too long. - Slot
Worker - A worker that should be invoked at every new slot.
Functions§
- check_
equivocation - Checks if the header is an equivocation and returns the proof in that case.
- proposing_
remaining_ duration - Calculate the remaining duration for block proposal taking into account whether any slots have
been skipped and applying the given lenience strategy. If
max_block_proposal_slot_portion
is not none this method guarantees that the returned duration must be lower or equal toslot_info.duration * max_block_proposal_slot_portion
. - slot_
lenience_ exponential - Calculate a slot duration lenience based on the number of missed slots from current
to parent. If the number of skipped slots is greater than 0 this method will apply
an exponential backoff of at most
2^7 * slot_duration
, if no slots were skipped this method will returnNone.
- slot_
lenience_ linear - Calculate a slot duration lenience based on the number of missed slots from current
to parent. If the number of skipped slots is greater than 0 this method will apply
a linear backoff of at most
20 * slot_duration
, if no slots were skipped this method will returnNone.
- start_
slot_ worker - Start a new slot worker.
- time_
until_ next_ slot - Returns the duration until the next slot from now.
Type Aliases§
- Storage
Changes - The changes that need to applied to the storage to create the state for a block.