Refactoring Checkpoint: (WIP)
This commit is contained in:
@@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { features = ["derive"], workspace = true, default-features = true }
|
||||
fork-tree = { workspace = true, default-features = true }
|
||||
pez-fork-tree = { workspace = true, default-features = true }
|
||||
pezsc-client-api = { workspace = true, default-features = true }
|
||||
pezsc-consensus = { workspace = true, default-features = true }
|
||||
pezsp-blockchain = { workspace = true, default-features = true }
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
pub mod migration;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use fork_tree::{FilterAction, ForkTree};
|
||||
use pez_fork_tree::{FilterAction, ForkTree};
|
||||
use pezsc_client_api::utils::is_descendent_of;
|
||||
use pezsp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata};
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor, One, Zero};
|
||||
@@ -195,7 +195,7 @@ where
|
||||
}
|
||||
|
||||
/// Increment the epoch, yielding an `IncrementedEpoch` to be imported
|
||||
/// into the fork-tree.
|
||||
/// into the pez-fork-tree.
|
||||
pub fn increment(&self, next_descriptor: E::NextEpochDescriptor) -> IncrementedEpoch<E> {
|
||||
let next = self.as_ref().increment(next_descriptor);
|
||||
let to_persist = match *self {
|
||||
@@ -305,7 +305,7 @@ impl<E: Epoch> PersistedEpochHeader<E> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A fresh, incremented epoch to import into the underlying fork-tree.
|
||||
/// A fresh, incremented epoch to import into the underlying pez-fork-tree.
|
||||
///
|
||||
/// Create this with `ViableEpoch::increment`.
|
||||
#[must_use = "Freshly-incremented epoch must be imported with `EpochChanges::import`"]
|
||||
@@ -401,7 +401,7 @@ where
|
||||
hash: &Hash,
|
||||
number: Number,
|
||||
slot: E::Slot,
|
||||
) -> Result<(), fork_tree::Error<D::Error>> {
|
||||
) -> Result<(), pez_fork_tree::Error<D::Error>> {
|
||||
let is_descendent_of = descendent_of_builder.build_is_descendent_of(None);
|
||||
|
||||
let predicate = |epoch: &PersistedEpochHeader<E>| match *epoch {
|
||||
@@ -518,7 +518,7 @@ where
|
||||
parent_number: Number,
|
||||
slot: E::Slot,
|
||||
make_genesis: G,
|
||||
) -> Result<Option<E>, fork_tree::Error<D::Error>>
|
||||
) -> Result<Option<E>, pez_fork_tree::Error<D::Error>>
|
||||
where
|
||||
G: FnOnce(E::Slot) -> E,
|
||||
E: Clone,
|
||||
@@ -543,13 +543,13 @@ where
|
||||
parent_hash: &Hash,
|
||||
parent_number: Number,
|
||||
slot: E::Slot,
|
||||
) -> Result<Option<ViableEpochDescriptor<Hash, Number, E>>, fork_tree::Error<D::Error>> {
|
||||
) -> Result<Option<ViableEpochDescriptor<Hash, Number, E>>, pez_fork_tree::Error<D::Error>> {
|
||||
if parent_number == Zero::zero() {
|
||||
// need to insert the genesis epoch.
|
||||
return Ok(Some(ViableEpochDescriptor::UnimportedGenesis(slot)));
|
||||
}
|
||||
|
||||
// find_node_where will give you the node in the fork-tree which is an ancestor
|
||||
// find_node_where will give you the node in the pez-fork-tree which is an ancestor
|
||||
// of the `parent_hash` by default. if the last epoch was signalled at the parent_hash,
|
||||
// then it won't be returned. we need to create a new fake chain head hash which
|
||||
// "descends" from our parent-hash.
|
||||
@@ -616,7 +616,7 @@ where
|
||||
number: Number,
|
||||
parent_hash: Hash,
|
||||
epoch: IncrementedEpoch<E>,
|
||||
) -> Result<(), fork_tree::Error<D::Error>> {
|
||||
) -> Result<(), pez_fork_tree::Error<D::Error>> {
|
||||
let is_descendent_of =
|
||||
descendent_of_builder.build_is_descendent_of(Some((hash, parent_hash)));
|
||||
let IncrementedEpoch(epoch) = epoch;
|
||||
@@ -625,7 +625,7 @@ where
|
||||
let res = self.inner.import(hash, number, header, &is_descendent_of);
|
||||
|
||||
match res {
|
||||
Ok(_) | Err(fork_tree::Error::Duplicate) => {
|
||||
Ok(_) | Err(pez_fork_tree::Error::Duplicate) => {
|
||||
self.epochs.insert((hash, number), epoch);
|
||||
Ok(())
|
||||
},
|
||||
@@ -641,14 +641,14 @@ where
|
||||
let persisted = PersistedEpoch::Regular(current);
|
||||
let header = PersistedEpochHeader::from(&persisted);
|
||||
let _res = self.inner.import(parent_hash, number - One::one(), header, &|_, _| {
|
||||
Ok(false) as Result<bool, fork_tree::Error<ClientError>>
|
||||
Ok(false) as Result<bool, pez_fork_tree::Error<ClientError>>
|
||||
});
|
||||
self.epochs.insert((parent_hash, number - One::one()), persisted);
|
||||
|
||||
let persisted = PersistedEpoch::Regular(next);
|
||||
let header = PersistedEpochHeader::from(&persisted);
|
||||
let _res = self.inner.import(hash, number, header, &|_, _| {
|
||||
Ok(true) as Result<bool, fork_tree::Error<ClientError>>
|
||||
Ok(true) as Result<bool, pez_fork_tree::Error<ClientError>>
|
||||
});
|
||||
self.epochs.insert((hash, number), persisted);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
use crate::{Epoch, EpochChanges, PersistedEpoch, PersistedEpochHeader};
|
||||
use codec::{Decode, Encode};
|
||||
use fork_tree::ForkTree;
|
||||
use pez_fork_tree::ForkTree;
|
||||
use pezsp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user