polkadot: eradicate LeafStatus (#1565)

Fixes #768.
This commit is contained in:
ordian
2023-10-23 16:22:37 +02:00
committed by GitHub
parent 9505243780
commit 5ca909cc09
15 changed files with 21 additions and 106 deletions
-31
View File
@@ -51,35 +51,6 @@ pub use polkadot_node_jaeger as jaeger;
/// If there are greater than this number of slots, then we fall back to a heap vector.
const ACTIVE_LEAVES_SMALLVEC_CAPACITY: usize = 8;
/// The status of an activated leaf.
#[derive(Clone, Debug, PartialEq)]
pub enum LeafStatus {
/// A leaf is fresh when it's the first time the leaf has been encountered.
/// Most leaves should be fresh.
Fresh,
/// A leaf is stale when it's encountered for a subsequent time. This will happen
/// when the chain is reverted or the fork-choice rule abandons some chain.
Stale,
}
impl LeafStatus {
/// Returns a `bool` indicating fresh status.
pub fn is_fresh(&self) -> bool {
match *self {
LeafStatus::Fresh => true,
LeafStatus::Stale => false,
}
}
/// Returns a `bool` indicating stale status.
pub fn is_stale(&self) -> bool {
match *self {
LeafStatus::Fresh => false,
LeafStatus::Stale => true,
}
}
}
/// Activated leaf.
#[derive(Debug, Clone)]
pub struct ActivatedLeaf {
@@ -87,8 +58,6 @@ pub struct ActivatedLeaf {
pub hash: Hash,
/// The block number.
pub number: BlockNumber,
/// The status of the leaf.
pub status: LeafStatus,
/// A handle to unpin the block on drop.
pub unpin_handle: UnpinHandle,
/// An associated [`jaeger::Span`].