pub type EpochChangesFor<Block, Epoch> = EpochChanges<<Block as BlockT>::Hash, NumberFor<Block>, Epoch>;
Expand description
Type alias to produce the epoch-changes tree from a block type.
Aliased Type§
struct EpochChangesFor<Block, Epoch> { /* private fields */ }
Implementations
Source§impl<Hash, Number, E: Epoch> EpochChanges<Hash, Number, E>
impl<Hash, Number, E: Epoch> EpochChanges<Hash, Number, E>
Sourcepub fn rebalance(&mut self)
pub fn rebalance(&mut self)
Rebalances the tree of epoch changes so that it is sorted by length of fork (longest fork first).
Sourcepub fn map<B, F>(self, f: F) -> EpochChanges<Hash, Number, B>
pub fn map<B, F>(self, f: F) -> EpochChanges<Hash, Number, B>
Map the epoch changes from one storing data to a different one.
Sourcepub fn prune_finalized<D: IsDescendentOfBuilder<Hash>>(
&mut self,
descendent_of_builder: D,
hash: &Hash,
number: Number,
slot: E::Slot,
) -> Result<(), Error<D::Error>>
pub fn prune_finalized<D: IsDescendentOfBuilder<Hash>>( &mut self, descendent_of_builder: D, hash: &Hash, number: Number, slot: E::Slot, ) -> Result<(), Error<D::Error>>
Prune out finalized epochs, except for the ancestor of the finalized block. The given slot should be the slot number at which the finalized block was authored.
Sourcepub fn epoch(&self, id: &EpochIdentifier<Hash, Number>) -> Option<&E>
pub fn epoch(&self, id: &EpochIdentifier<Hash, Number>) -> Option<&E>
Get a reference to an epoch with given identifier.
Sourcepub fn viable_epoch<G>(
&self,
descriptor: &ViableEpochDescriptor<Hash, Number, E>,
make_genesis: G,
) -> Option<ViableEpoch<E, &E>>
pub fn viable_epoch<G>( &self, descriptor: &ViableEpochDescriptor<Hash, Number, E>, make_genesis: G, ) -> Option<ViableEpoch<E, &E>>
Get a reference to a viable epoch with given descriptor.
Sourcepub fn epoch_mut(
&mut self,
id: &EpochIdentifier<Hash, Number>,
) -> Option<&mut E>
pub fn epoch_mut( &mut self, id: &EpochIdentifier<Hash, Number>, ) -> Option<&mut E>
Get a mutable reference to an epoch with given identifier.
Sourcepub fn viable_epoch_mut<G>(
&mut self,
descriptor: &ViableEpochDescriptor<Hash, Number, E>,
make_genesis: G,
) -> Option<ViableEpoch<E, &mut E>>
pub fn viable_epoch_mut<G>( &mut self, descriptor: &ViableEpochDescriptor<Hash, Number, E>, make_genesis: G, ) -> Option<ViableEpoch<E, &mut E>>
Get a mutable reference to a viable epoch with given descriptor.
Sourcepub fn epoch_data<G>(
&self,
descriptor: &ViableEpochDescriptor<Hash, Number, E>,
make_genesis: G,
) -> Option<E>
pub fn epoch_data<G>( &self, descriptor: &ViableEpochDescriptor<Hash, Number, E>, make_genesis: G, ) -> Option<E>
Get the epoch data from an epoch descriptor.
Note that this function ignores the fact that an genesis epoch might need to be imported. Mostly useful for testing.
Sourcepub fn epoch_data_for_child_of<D: IsDescendentOfBuilder<Hash>, G>(
&self,
descendent_of_builder: D,
parent_hash: &Hash,
parent_number: Number,
slot: E::Slot,
make_genesis: G,
) -> Result<Option<E>, Error<D::Error>>
pub fn epoch_data_for_child_of<D: IsDescendentOfBuilder<Hash>, G>( &self, descendent_of_builder: D, parent_hash: &Hash, parent_number: Number, slot: E::Slot, make_genesis: G, ) -> Result<Option<E>, Error<D::Error>>
Finds the epoch data for a child of the given block. Similar to
epoch_descriptor_for_child_of
but returns the full data.
Note that this function ignores the fact that an genesis epoch might need to be imported. Mostly useful for testing.
Sourcepub fn epoch_descriptor_for_child_of<D: IsDescendentOfBuilder<Hash>>(
&self,
descendent_of_builder: D,
parent_hash: &Hash,
parent_number: Number,
slot: E::Slot,
) -> Result<Option<ViableEpochDescriptor<Hash, Number, E>>, Error<D::Error>>
pub fn epoch_descriptor_for_child_of<D: IsDescendentOfBuilder<Hash>>( &self, descendent_of_builder: D, parent_hash: &Hash, parent_number: Number, slot: E::Slot, ) -> Result<Option<ViableEpochDescriptor<Hash, Number, E>>, Error<D::Error>>
Finds the epoch for a child of the given block, assuming the given slot number.
If the returned epoch is an UnimportedGenesis
epoch, it should be imported into the
tree.
Sourcepub fn import<D: IsDescendentOfBuilder<Hash>>(
&mut self,
descendent_of_builder: D,
hash: Hash,
number: Number,
parent_hash: Hash,
epoch: IncrementedEpoch<E>,
) -> Result<(), Error<D::Error>>
pub fn import<D: IsDescendentOfBuilder<Hash>>( &mut self, descendent_of_builder: D, hash: Hash, number: Number, parent_hash: Hash, epoch: IncrementedEpoch<E>, ) -> Result<(), Error<D::Error>>
Import a new epoch-change, signalled at the given block.
This assumes that the given block is prospective (i.e. has not been imported yet), but its parent has. This is why the parent hash needs to be provided.
Sourcepub fn reset(
&mut self,
parent_hash: Hash,
hash: Hash,
number: Number,
current: E,
next: E,
)
pub fn reset( &mut self, parent_hash: Hash, hash: Hash, number: Number, current: E, next: E, )
Reset to a specified pair of epochs, as if they were announced at blocks parent_hash
and
hash
.
Sourcepub fn revert<D: IsDescendentOfBuilder<Hash>>(
&mut self,
descendent_of_builder: D,
hash: Hash,
number: Number,
)
pub fn revert<D: IsDescendentOfBuilder<Hash>>( &mut self, descendent_of_builder: D, hash: Hash, number: Number, )
Revert to a specified block given its hash
and number
.
This removes all the epoch changes information that were announced by
all the given block descendants.
Sourcepub fn tree(&self) -> &ForkTree<Hash, Number, PersistedEpochHeader<E>>
pub fn tree(&self) -> &ForkTree<Hash, Number, PersistedEpochHeader<E>>
Return the inner fork tree (mostly useful for testing)
Trait Implementations
Source§impl<Hash: Clone, Number: Clone, E: Clone + Epoch> Clone for EpochChanges<Hash, Number, E>
impl<Hash: Clone, Number: Clone, E: Clone + Epoch> Clone for EpochChanges<Hash, Number, E>
Source§fn clone(&self) -> EpochChanges<Hash, Number, E>
fn clone(&self) -> EpochChanges<Hash, Number, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more