some initial spans for approval voting (#2525)

* some initial spans for approval voting

* add stage earlier
This commit is contained in:
Robert Habermeier
2021-02-25 11:56:50 -06:00
committed by GitHub
parent 4e3dba91be
commit 49705026e0
7 changed files with 61 additions and 8 deletions
+12 -1
View File
@@ -45,7 +45,8 @@
//! ```
use sp_core::traits::SpawnNamed;
use polkadot_primitives::v1::{CandidateHash, Hash, PoV, ValidatorIndex};
use polkadot_primitives::v1::{CandidateHash, Hash, PoV, ValidatorIndex, BlakeTwo256, HashT};
use parity_scale_codec::Encode;
use sc_network::PeerId;
use parking_lot::RwLock;
@@ -176,6 +177,7 @@ pub enum Stage {
AvailabilityDistribution = 5,
AvailabilityRecovery = 6,
BitfieldDistribution = 7,
ApprovalChecking = 8,
// Expand as needed, numbers should be ascending according to the stage
// through the inclusion pipeline, or according to the descriptions
// in [the path of a para chain block]
@@ -381,6 +383,15 @@ pub fn hash_span(hash: &Hash, span_name: &'static str) -> Span {
span
}
/// Creates a `Span` referring to the given descriptor, which should be unique.
#[inline(always)]
pub fn descriptor_span(descriptor: impl Encode, span_name: &'static str) -> Span {
INSTANCE.read_recursive().span(
|| { BlakeTwo256::hash_of(&descriptor) },
span_name,
).into()
}
/// Stateful convenience wrapper around [`mick_jaeger`].
pub enum Jaeger {
/// Launched and operational state.