mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 10:17:57 +00:00
Add block number to activated leaves and associated fixes (#2718)
* add number to `ActivatedLeavesUpdate` * update subsystem util and overseer * use new ActivatedLeaf everywhere * sort view * sorted and limited view in network bridge * use live block hash only if it's newer * grumples
This commit is contained in:
committed by
GitHub
parent
a4ed8aaab2
commit
064df81ee4
@@ -46,24 +46,35 @@ use self::messages::AllMessages;
|
||||
/// If there are greater than this number of slots, then we fall back to a heap vector.
|
||||
const ACTIVE_LEAVES_SMALLVEC_CAPACITY: usize = 8;
|
||||
|
||||
/// Activated leaf.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ActivatedLeaf {
|
||||
/// The block hash.
|
||||
pub hash: Hash,
|
||||
/// The block number.
|
||||
pub number: BlockNumber,
|
||||
/// An associated [`jaeger::Span`].
|
||||
///
|
||||
/// NOTE: Each span should only be kept active as long as the leaf is considered active and should be dropped
|
||||
/// when the leaf is deactivated.
|
||||
pub span: Arc<jaeger::Span>,
|
||||
}
|
||||
|
||||
/// Changes in the set of active leaves: the parachain heads which we care to work on.
|
||||
///
|
||||
/// Note that the activated and deactivated fields indicate deltas, not complete sets.
|
||||
#[derive(Clone, Default)]
|
||||
pub struct ActiveLeavesUpdate {
|
||||
/// New relay chain block hashes of interest and their associated [`jaeger::Span`].
|
||||
///
|
||||
/// NOTE: Each span should only be kept active as long as the leaf is considered active and should be dropped
|
||||
/// when the leaf is deactivated.
|
||||
pub activated: SmallVec<[(Hash, Arc<jaeger::Span>); ACTIVE_LEAVES_SMALLVEC_CAPACITY]>,
|
||||
/// New relay chain blocks of interest.
|
||||
pub activated: SmallVec<[ActivatedLeaf; ACTIVE_LEAVES_SMALLVEC_CAPACITY]>,
|
||||
/// Relay chain block hashes no longer of interest.
|
||||
pub deactivated: SmallVec<[Hash; ACTIVE_LEAVES_SMALLVEC_CAPACITY]>,
|
||||
}
|
||||
|
||||
impl ActiveLeavesUpdate {
|
||||
/// Create a ActiveLeavesUpdate with a single activated hash
|
||||
pub fn start_work(hash: Hash, span: Arc<jaeger::Span>) -> Self {
|
||||
Self { activated: [(hash, span)][..].into(), ..Default::default() }
|
||||
pub fn start_work(activated: ActivatedLeaf) -> Self {
|
||||
Self { activated: [activated][..].into(), ..Default::default() }
|
||||
}
|
||||
|
||||
/// Create a ActiveLeavesUpdate with a single deactivated hash
|
||||
@@ -83,17 +94,17 @@ impl PartialEq for ActiveLeavesUpdate {
|
||||
/// Instead, it means equality when `activated` and `deactivated` are considered as sets.
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.activated.len() == other.activated.len() && self.deactivated.len() == other.deactivated.len()
|
||||
&& self.activated.iter().all(|a| other.activated.iter().any(|o| a.0 == o.0))
|
||||
&& self.activated.iter().all(|a| other.activated.iter().any(|o| a.hash == o.hash))
|
||||
&& self.deactivated.iter().all(|a| other.deactivated.contains(a))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ActiveLeavesUpdate {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
struct Activated<'a>(&'a [(Hash, Arc<jaeger::Span>)]);
|
||||
struct Activated<'a>(&'a [ActivatedLeaf]);
|
||||
impl fmt::Debug for Activated<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_list().entries(self.0.iter().map(|e| e.0)).finish()
|
||||
f.debug_list().entries(self.0.iter().map(|e| e.hash)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user