Consistency with the Block trait name (#3129)

* Consistency with the Block trait name

* Line widths
This commit is contained in:
Pierre Krieger
2019-07-16 16:32:46 +02:00
committed by André Silva
parent 768eb1af4d
commit a22bb71029
7 changed files with 80 additions and 70 deletions
@@ -21,7 +21,7 @@ use std::sync::Arc;
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use linked_hash_map::{LinkedHashMap, Entry};
use hash_db::Hasher;
use runtime_primitives::traits::{Block, Header};
use runtime_primitives::traits::{Block as BlockT, Header};
use state_machine::{backend::Backend as StateBackend, TrieBackend};
use log::trace;
use super::{StorageCollection, ChildStorageCollection};
@@ -33,7 +33,7 @@ type ChildStorageKey = (Vec<u8>, Vec<u8>);
type StorageValue = Vec<u8>;
/// Shared canonical state cache.
pub struct Cache<B: Block, H: Hasher> {
pub struct Cache<B: BlockT, H: Hasher> {
/// Storage cache. `None` indicates that key is known to be missing.
lru_storage: LRUMap<StorageKey, Option<StorageValue>>,
/// Storage hashes cache. `None` indicates that key is known to be missing.
@@ -144,7 +144,7 @@ impl<K: EstimateSize + Eq + StdHash, V: EstimateSize> LRUMap<K, V> {
}
impl<B: Block, H: Hasher> Cache<B, H> {
impl<B: BlockT, H: Hasher> Cache<B, H> {
/// Returns the used memory size of the storage cache in bytes.
pub fn used_storage_cache_size(&self) -> usize {
self.lru_storage.used_size()
@@ -159,7 +159,7 @@ pub type SharedCache<B, H> = Arc<Mutex<Cache<B, H>>>;
const FIX_LRU_HASH_SIZE: usize = 65_536;
/// Create a new shared cache instance with given max memory usage.
pub fn new_shared_cache<B: Block, H: Hasher>(
pub fn new_shared_cache<B: BlockT, H: Hasher>(
shared_cache_size: usize,
child_ratio: (usize, usize),
) -> SharedCache<B, H> {
@@ -202,7 +202,7 @@ struct LocalCache<H: Hasher> {
}
/// Cache changes.
pub struct CacheChanges<H: Hasher, B: Block> {
pub struct CacheChanges<H: Hasher, B: BlockT> {
/// Shared canonical state cache.
shared_cache: SharedCache<B, H>,
/// Local cache of values for this state.
@@ -219,14 +219,14 @@ pub struct CacheChanges<H: Hasher, B: Block> {
/// For canonical instances local cache is accumulated and applied
/// in `sync_cache` along with the change overlay.
/// For non-canonical clones local cache and changes are dropped.
pub struct CachingState<H: Hasher, S: StateBackend<H>, B: Block> {
pub struct CachingState<H: Hasher, S: StateBackend<H>, B: BlockT> {
/// Backing state.
state: S,
/// Cache data.
pub cache: CacheChanges<H, B>
}
impl<H: Hasher, B: Block> CacheChanges<H, B> {
impl<H: Hasher, B: BlockT> CacheChanges<H, B> {
/// Propagate local cache into the shared cache and synchronize
/// the shared cache with the best block state.
/// This function updates the shared cache by removing entries
@@ -374,7 +374,7 @@ impl<H: Hasher, B: Block> CacheChanges<H, B> {
}
impl<H: Hasher, S: StateBackend<H>, B: Block> CachingState<H, S, B> {
impl<H: Hasher, S: StateBackend<H>, B: BlockT> CachingState<H, S, B> {
/// Create a new instance wrapping generic State and shared cache.
pub fn new(state: S, shared_cache: SharedCache<B, H>, parent_hash: Option<B::Hash>) -> CachingState<H, S, B> {
CachingState {
@@ -447,7 +447,7 @@ impl<H: Hasher, S: StateBackend<H>, B: Block> CachingState<H, S, B> {
}
}
impl<H: Hasher, S: StateBackend<H>, B:Block> StateBackend<H> for CachingState<H, S, B> {
impl<H: Hasher, S: StateBackend<H>, B: BlockT> StateBackend<H> for CachingState<H, S, B> {
type Error = S::Error;
type Transaction = S::Transaction;
type TrieBackendStorage = S::TrieBackendStorage;
+11 -11
View File
@@ -47,7 +47,7 @@ use client::{
};
use runtime_primitives::{generic::{self, BlockId, OpaqueDigestItemId}, Justification};
use runtime_primitives::traits::{Block, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member};
use runtime_primitives::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member};
use primitives::Pair;
use inherents::{InherentDataProviders, InherentData};
@@ -84,7 +84,7 @@ impl SlotDuration {
pub fn get_or_compute<A, B, C>(client: &C) -> CResult<Self>
where
A: Codec,
B: Block,
B: BlockT,
C: AuxStore + ProvideRuntimeApi,
C::Api: AuraApi<B, A>,
{
@@ -140,7 +140,7 @@ pub fn start_aura<B, C, SC, E, I, P, SO, Error, H>(
inherent_data_providers: InherentDataProviders,
force_authoring: bool,
) -> Result<impl Future<Item=(), Error=()>, consensus_common::Error> where
B: Block<Header=H>,
B: BlockT<Header=H>,
C: ProvideRuntimeApi + ProvideCache<B> + AuxStore + Send + Sync,
C::Api: AuraApi<B, AuthorityId<P>>,
SC: SelectChain<B>,
@@ -187,7 +187,7 @@ struct AuraWorker<C, E, I, P, SO> {
}
impl<H, B, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I, P, SO> where
B: Block<Header=H>,
B: BlockT<Header=H>,
C: ProvideRuntimeApi + ProvideCache<B> + Sync,
C::Api: AuraApi<B, AuthorityId<P>>,
E: Environment<B, Error=Error>,
@@ -358,7 +358,7 @@ macro_rules! aura_err {
};
}
fn find_pre_digest<B: Block, P: Pair>(header: &B::Header) -> Result<u64, String>
fn find_pre_digest<B: BlockT, P: Pair>(header: &B::Header) -> Result<u64, String>
where DigestItemFor<B>: CompatibleDigestItem<P>,
P::Signature: Decode,
P::Public: Encode + Decode + PartialEq + Clone,
@@ -382,7 +382,7 @@ fn find_pre_digest<B: Block, P: Pair>(header: &B::Header) -> Result<u64, String>
/// This digest item will always return `Some` when used with `as_aura_seal`.
//
// FIXME #1018 needs misbehavior types
fn check_header<C, B: Block, P: Pair>(
fn check_header<C, B: BlockT, P: Pair>(
client: &C,
slot_now: u64,
mut header: B::Header,
@@ -451,7 +451,7 @@ pub struct AuraVerifier<C, P> {
impl<C, P> AuraVerifier<C, P>
where P: Send + Sync + 'static
{
fn check_inherents<B: Block>(
fn check_inherents<B: BlockT>(
&self,
block: B,
block_id: BlockId<B>,
@@ -501,7 +501,7 @@ impl<C, P> AuraVerifier<C, P>
}
#[forbid(deprecated)]
impl<B: Block, C, P> Verifier<B> for AuraVerifier<C, P> where
impl<B: BlockT, C, P> Verifier<B> for AuraVerifier<C, P> where
C: ProvideRuntimeApi + Send + Sync + client::backend::AuxStore + ProvideCache<B>,
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>>,
DigestItemFor<B>: CompatibleDigestItem<P>,
@@ -604,7 +604,7 @@ impl<B: Block, C, P> Verifier<B> for AuraVerifier<C, P> where
fn initialize_authorities_cache<A, B, C>(client: &C) -> Result<(), ConsensusError> where
A: Codec,
B: Block,
B: BlockT,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: AuraApi<B, A>,
{
@@ -638,7 +638,7 @@ fn initialize_authorities_cache<A, B, C>(client: &C) -> Result<(), ConsensusErro
#[allow(deprecated)]
fn authorities<A, B, C>(client: &C, at: &BlockId<B>) -> Result<Vec<A>, ConsensusError> where
A: Codec,
B: Block,
B: BlockT,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: AuraApi<B, A>,
{
@@ -679,7 +679,7 @@ pub fn import_queue<B, C, P>(
client: Arc<C>,
inherent_data_providers: InherentDataProviders,
) -> Result<AuraImportQueue<B>, consensus_common::Error> where
B: Block,
B: BlockT,
C: 'static + ProvideRuntimeApi + ProvideCache<B> + Send + Sync + AuxStore,
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>>,
DigestItemFor<B>: CompatibleDigestItem<P>,
+11 -11
View File
@@ -37,7 +37,7 @@ use consensus_common::import_queue::{
use consensus_common::well_known_cache_keys::Id as CacheKeyId;
use runtime_primitives::{generic, generic::{BlockId, OpaqueDigestItemId}, Justification};
use runtime_primitives::traits::{
Block, Header, DigestItemFor, ProvideRuntimeApi,
Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi,
SimpleBitOps, Zero,
};
use std::{sync::Arc, u64, fmt::{Debug, Display}, time::{Instant, Duration}};
@@ -95,7 +95,7 @@ pub struct Config(slots::SlotDuration<BabeConfiguration>);
impl Config {
/// Either fetch the slot duration from disk or compute it from the genesis
/// state.
pub fn get_or_compute<B: Block, C>(client: &C) -> CResult<Self>
pub fn get_or_compute<B: BlockT, C>(client: &C) -> CResult<Self>
where
C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi<B>,
{
@@ -185,7 +185,7 @@ pub fn start_babe<B, C, SC, E, I, SO, Error, H>(BabeParams {
impl Future<Item=(), Error=()>,
consensus_common::Error,
> where
B: Block<Header=H>,
B: BlockT<Header=H>,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: BabeApi<B>,
SC: SelectChain<B>,
@@ -228,7 +228,7 @@ struct BabeWorker<C, E, I, SO> {
}
impl<Hash, H, B, C, E, I, Error, SO> SlotWorker<B> for BabeWorker<C, E, I, SO> where
B: Block<Header=H, Hash=Hash>,
B: BlockT<Header=H, Hash=Hash>,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: BabeApi<B>,
E: Environment<B, Error=Error>,
@@ -418,7 +418,7 @@ macro_rules! babe_err {
};
}
fn find_pre_digest<B: Block>(header: &B::Header) -> Result<BabePreDigest, String>
fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<BabePreDigest, String>
where DigestItemFor<B>: CompatibleDigestItem,
{
let mut pre_digest: Option<_> = None;
@@ -443,7 +443,7 @@ fn find_pre_digest<B: Block>(header: &B::Header) -> Result<BabePreDigest, String
/// This digest item will always return `Some` when used with `as_babe_pre_digest`.
//
// FIXME #1018 needs misbehavior types
fn check_header<B: Block + Sized, C: AuxStore>(
fn check_header<B: BlockT + Sized, C: AuxStore>(
client: &C,
slot_now: u64,
mut header: B::Header,
@@ -531,7 +531,7 @@ pub struct BabeVerifier<C> {
}
impl<C> BabeVerifier<C> {
fn check_inherents<B: Block>(
fn check_inherents<B: BlockT>(
&self,
block: B,
block_id: BlockId<B>,
@@ -587,7 +587,7 @@ fn median_algorithm(
}
}
impl<B: Block, C> Verifier<B> for BabeVerifier<C> where
impl<B: BlockT, C> Verifier<B> for BabeVerifier<C> where
C: ProvideRuntimeApi + Send + Sync + AuxStore + ProvideCache<B>,
C::Api: BlockBuilderApi<B> + BabeApi<B>,
DigestItemFor<B>: CompatibleDigestItem,
@@ -701,7 +701,7 @@ fn authorities<B, C>(client: &C, at: &BlockId<B>) -> Result<
Vec<AuthorityId>,
ConsensusError,
> where
B: Block,
B: BlockT,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: BabeApi<B>,
{
@@ -796,7 +796,7 @@ fn claim_slot(
}
fn initialize_authorities_cache<B, C>(client: &C) -> Result<(), ConsensusError> where
B: Block,
B: BlockT,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: BabeApi<B>,
{
@@ -834,7 +834,7 @@ pub fn import_queue<B, C, E>(
client: Arc<C>,
inherent_data_providers: InherentDataProviders,
) -> Result<(BabeImportQueue<B>, BabeLink), consensus_common::Error> where
B: Block,
B: BlockT,
C: 'static + ProvideRuntimeApi + ProvideCache<B> + Send + Sync + AuxStore,
C::Api: BlockBuilderApi<B> + BabeApi<B>,
DigestItemFor<B>: CompatibleDigestItem,
+3 -3
View File
@@ -31,7 +31,7 @@
use std::sync::Arc;
use std::time::Duration;
use runtime_primitives::traits::{Block, DigestFor};
use runtime_primitives::traits::{Block as BlockT, DigestFor};
use futures::prelude::*;
pub use inherents::InherentData;
@@ -53,7 +53,7 @@ pub use block_import::{
pub use select_chain::SelectChain;
/// Environment producer for a Consensus instance. Creates proposer instance and communication streams.
pub trait Environment<B: Block> {
pub trait Environment<B: BlockT> {
/// The proposer type this creates.
type Proposer: Proposer<B>;
/// Error which can occur upon creation.
@@ -71,7 +71,7 @@ pub trait Environment<B: Block> {
/// block.
///
/// Proposers are generic over bits of "consensus data" which are engine-specific.
pub trait Proposer<B: Block> {
pub trait Proposer<B: BlockT> {
/// Error type which can occur when proposing or evaluating.
type Error: From<Error> + ::std::fmt::Debug + 'static;
/// Future that resolves to a committed proposal.
+26 -16
View File
@@ -150,7 +150,7 @@ pub type Misbehavior<H> = rhododendron::Misbehavior<H, LocalizedSignature>;
pub type SharedOfflineTracker = Arc<RwLock<OfflineTracker>>;
/// A proposer for a rhododendron instance. This must implement the base proposer logic.
pub trait LocalProposer<B: Block>: BaseProposer<B, Error=Error> {
pub trait LocalProposer<B: BlockT>: BaseProposer<B, Error=Error> {
/// Import witnessed rhododendron misbehavior.
fn import_misbehavior(&self, misbehavior: Vec<(AuthorityId, Misbehavior<B::Hash>)>);
@@ -224,7 +224,7 @@ struct RoundCache<H> {
}
/// Instance of BFT agreement.
struct BftInstance<B: Block, P> {
struct BftInstance<B: BlockT, P> {
key: Arc<ed25519::Pair>,
authorities: Vec<AuthorityId>,
parent_hash: B::Hash,
@@ -233,7 +233,7 @@ struct BftInstance<B: Block, P> {
proposer: P,
}
impl<B: Block, P: LocalProposer<B>> BftInstance<B, P>
impl<B: BlockT, P: LocalProposer<B>> BftInstance<B, P>
where
B: Clone + Eq,
B::Hash: ::std::hash::Hash
@@ -262,7 +262,7 @@ impl<B: Block, P: LocalProposer<B>> BftInstance<B, P>
}
}
impl<B: Block, P: LocalProposer<B>> rhododendron::Context for BftInstance<B, P>
impl<B: BlockT, P: LocalProposer<B>> rhododendron::Context for BftInstance<B, P>
where
B: Clone + Eq,
B::Hash: ::std::hash::Hash,
@@ -465,7 +465,7 @@ impl Drop for AgreementHandle {
/// is notified of.
///
/// This assumes that it is being run in the context of a tokio runtime.
pub struct BftService<B: Block, P, I> {
pub struct BftService<B: BlockT, P, I> {
client: Arc<I>,
live_agreement: Mutex<Option<(B::Header, AgreementHandle)>>,
round_cache: Arc<Mutex<RoundCache<B::Hash>>>,
@@ -638,14 +638,14 @@ impl<B, P, I> BftService<B, P, I>
/// This stream is localized to a specific parent block-hash, as all messages
/// will be signed in a way that accounts for it. When using this with
/// `BftService::build_upon`, the user should take care to use the same hash as for that.
pub struct CheckedStream<B: Block, S> {
pub struct CheckedStream<B: BlockT, S> {
inner: S,
local_id: AuthorityId,
authorities: Vec<AuthorityId>,
parent_hash: B::Hash,
}
impl<B: Block, S> CheckedStream<B, S> {
impl<B: BlockT, S> CheckedStream<B, S> {
/// Construct a new checked stream.
pub fn new(
inner: S,
@@ -662,7 +662,7 @@ impl<B: Block, S> CheckedStream<B, S> {
}
}
impl<B: Block, S: Stream<Item=Vec<u8>>> Stream for CheckedStream<B, S>
impl<B: BlockT, S: Stream<Item=Vec<u8>>> Stream for CheckedStream<B, S>
where S::Error: From<InputStreamConcluded>,
{
type Item = Communication<B>;
@@ -780,7 +780,7 @@ fn check_justification_signed_message<H>(
/// Provide all valid authorities.
///
/// On failure, returns the justification back.
pub fn check_justification<B: Block>(
pub fn check_justification<B: BlockT>(
authorities: &[AuthorityId],
parent: B::Hash,
just: UncheckedJustification<B::Hash>
@@ -795,9 +795,11 @@ pub fn check_justification<B: Block>(
/// Provide all valid authorities.
///
/// On failure, returns the justification back.
pub fn check_prepare_justification<B: Block>(authorities: &[AuthorityId], parent: B::Hash, just: UncheckedJustification<B::Hash>)
-> Result<PrepareJustification<B::Hash>, UncheckedJustification<B::Hash>>
{
pub fn check_prepare_justification<B: BlockT>(
authorities: &[AuthorityId],
parent: B::Hash,
just: UncheckedJustification<B::Hash>
) -> Result<PrepareJustification<B::Hash>, UncheckedJustification<B::Hash>> {
let vote: Action<B, B::Hash> = Action::Prepare(just.0.round_number as u32, just.0.digest.clone());
let message = localized_encode(parent, vote);
@@ -824,7 +826,7 @@ pub fn check_proposal<B: Block + Clone>(
/// Check vote message signatures and authority.
/// Provide all valid authorities.
pub fn check_vote<B: Block>(
pub fn check_vote<B: BlockT>(
authorities: &[AuthorityId],
parent_hash: &B::Hash,
vote: &rhododendron::LocalizedVote<B::Hash, AuthorityId, LocalizedSignature>)
@@ -842,7 +844,11 @@ pub fn check_vote<B: Block>(
check_action::<B>(action, parent_hash, &vote.signature)
}
fn check_action<B: Block>(action: Action<B, B::Hash>, parent_hash: &B::Hash, sig: &LocalizedSignature) -> Result<(), Error> {
fn check_action<B: BlockT>(
action: Action<B, B::Hash>,
parent_hash: &B::Hash,
sig: &LocalizedSignature
) -> Result<(), Error> {
let message = localized_encode(*parent_hash, action);
if ed25519::Pair::verify(&sig.signature, &message, &sig.signer) {
Ok(())
@@ -981,7 +987,8 @@ impl<N, C, A> consensus::Environment<<C as AuthoringApi>::Block> for ProposerFac
let id = BlockId::hash(parent_hash);
let random_seed = self.client.random_seed(&id)?;
let random_seed = <<<C as AuthoringApi>::Block as BlockT>::Header as HeaderT>::Hashing::hash(random_seed.as_ref());
let random_seed = <<<C as AuthoringApi>::Block as BlockT>::Header as HeaderT>
::Hashing::hash(random_seed.as_ref());
let validators = self.client.validators(&id)?;
self.offline.write().note_new_block(&validators[..]);
@@ -1225,7 +1232,10 @@ impl<C, A> LocalProposer<<C as AuthoringApi>::Block> for Proposer<C, A> where
proposer
}
fn import_misbehavior(&self, _misbehavior: Vec<(AuthorityId, Misbehavior<<<C as AuthoringApi>::Block as BlockT>::Hash>)>) {
fn import_misbehavior(
&self,
_misbehavior: Vec<(AuthorityId, Misbehavior<<<C as AuthoringApi>::Block as BlockT>::Hash>)>
) {
use rhododendron::Misbehavior as GenericMisbehavior;
use runtime_primitives::bft::{MisbehaviorKind, MisbehaviorReport};
use node_runtime::{Call, UncheckedExtrinsic, ConsensusCall};
+4 -4
View File
@@ -38,12 +38,12 @@ use futures::{
use inherents::{InherentData, InherentDataProviders};
use log::{debug, error, info, warn};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{ApiRef, Block, ProvideRuntimeApi};
use runtime_primitives::traits::{ApiRef, Block as BlockT, ProvideRuntimeApi};
use std::fmt::Debug;
use std::ops::Deref;
/// A worker that should be invoked at every new slot.
pub trait SlotWorker<B: Block> {
pub trait SlotWorker<B: BlockT> {
/// The type of the future that will be returned when a new slot is
/// triggered.
type OnSlot: IntoFuture<Item = (), Error = consensus_common::Error>;
@@ -78,7 +78,7 @@ pub fn start_slot_worker<B, C, W, T, SO, SC>(
timestamp_extractor: SC,
) -> impl Future<Item = (), Error = ()>
where
B: Block,
B: BlockT,
C: SelectChain<B> + Clone,
W: SlotWorker<B>,
SO: SyncOracle + Send + Clone,
@@ -193,7 +193,7 @@ impl<T: Clone> SlotDuration<T> {
///
/// `slot_key` is marked as `'static`, as it should really be a
/// compile-time constant.
pub fn get_or_compute<B: Block, C, CB>(client: &C, cb: CB) -> ::client::error::Result<Self> where
pub fn get_or_compute<B: BlockT, C, CB>(client: &C, cb: CB) -> ::client::error::Result<Self> where
C: client::backend::AuxStore,
C: ProvideRuntimeApi,
CB: FnOnce(ApiRef<C::Api>, &BlockId<B>) -> ::client::error::Result<T>,
+16 -16
View File
@@ -42,7 +42,7 @@ use log::{debug, trace, warn, info, error};
use runtime_primitives::{
Justification,
generic::BlockId,
traits::{Block, Header, NumberFor, Zero, One, CheckedSub, SaturatedConversion}
traits::{Block as BlockT, Header, NumberFor, Zero, One, CheckedSub, SaturatedConversion}
};
use std::{fmt, ops::Range, collections::{HashMap, HashSet, VecDeque}, sync::Arc};
@@ -94,7 +94,7 @@ const BAD_JUSTIFICATION_REPUTATION_CHANGE: i32 = -(1 << 16);
/// The main data structure which contains all the state for a chains
/// active syncing strategy.
pub struct ChainSync<B: Block> {
pub struct ChainSync<B: BlockT> {
/// Chain client.
client: Arc<dyn crate::chain::Client<B>>,
/// The active peers that we are using to sync and their PeerSync status
@@ -124,7 +124,7 @@ pub struct ChainSync<B: Block> {
/// All the data we have about a Peer that we are trying to sync with
#[derive(Debug, Clone)]
pub struct PeerSync<B: Block> {
pub struct PeerSync<B: BlockT> {
/// The common number is the block number that is a common point of
/// ancestry for both our chains (as far as we know).
pub common_number: NumberFor<B>,
@@ -142,7 +142,7 @@ pub struct PeerSync<B: Block> {
/// The sync status of a peer we are trying to sync with
#[derive(Debug)]
pub struct PeerInfo<B: Block> {
pub struct PeerInfo<B: BlockT> {
/// Their best block hash.
pub best_hash: B::Hash,
/// Their best block number.
@@ -154,7 +154,7 @@ pub struct PeerInfo<B: Block> {
/// Generally two categories, "busy" or `Available`. If busy, the enum
/// defines what we are busy with.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum PeerSyncState<B: Block> {
pub enum PeerSyncState<B: BlockT> {
/// Available for sync requests.
Available,
/// Searching for ancestors the Peer has in common with us.
@@ -171,7 +171,7 @@ pub enum PeerSyncState<B: Block> {
DownloadingFinalityProof(B::Hash)
}
impl<B: Block> PeerSyncState<B> {
impl<B: BlockT> PeerSyncState<B> {
pub fn is_available(&self) -> bool {
if let PeerSyncState::Available = self {
true
@@ -192,7 +192,7 @@ pub enum SyncState {
/// Syncing status and statistics.
#[derive(Clone)]
pub struct Status<B: Block> {
pub struct Status<B: BlockT> {
/// Current global sync state.
pub state: SyncState,
/// Target sync block number.
@@ -215,7 +215,7 @@ impl std::error::Error for BadPeer {}
/// Result of [`ChainSync::on_block_data`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OnBlockData<B: Block> {
pub enum OnBlockData<B: BlockT> {
/// The block should be imported.
Import(BlockOrigin, Vec<IncomingBlock<B>>),
/// A new block request needs to be made to the given peer.
@@ -224,7 +224,7 @@ pub enum OnBlockData<B: Block> {
/// Result of [`ChainSync::on_block_announce`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OnBlockAnnounce<B: Block> {
pub enum OnBlockAnnounce<B: BlockT> {
/// The announcement does not require further handling.
Nothing,
/// The announcement header should be imported.
@@ -235,7 +235,7 @@ pub enum OnBlockAnnounce<B: Block> {
/// Result of [`ChainSync::on_block_justification`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OnBlockJustification<B: Block> {
pub enum OnBlockJustification<B: BlockT> {
/// The justification needs no further handling.
Nothing,
/// The justification should be imported.
@@ -249,7 +249,7 @@ pub enum OnBlockJustification<B: Block> {
/// Result of [`ChainSync::on_block_finality_proof`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OnBlockFinalityProof<B: Block> {
pub enum OnBlockFinalityProof<B: BlockT> {
/// The proof needs no further handling.
Nothing,
/// The proof should be imported.
@@ -261,7 +261,7 @@ pub enum OnBlockFinalityProof<B: Block> {
}
}
impl<B: Block> ChainSync<B> {
impl<B: BlockT> ChainSync<B> {
/// Create a new instance.
pub fn new(
role: Roles,
@@ -1097,7 +1097,7 @@ impl<B: Block> ChainSync<B> {
/// Request the ancestry for a block. Sends a request for header and justification for the given
/// block number. Used during ancestry search.
fn ancestry_request<B: Block>(block: NumberFor<B>) -> BlockRequest<B> {
fn ancestry_request<B: BlockT>(block: NumberFor<B>) -> BlockRequest<B> {
message::generic::BlockRequest {
id: 0,
fields: BlockAttributes::HEADER | BlockAttributes::JUSTIFICATION,
@@ -1111,7 +1111,7 @@ fn ancestry_request<B: Block>(block: NumberFor<B>) -> BlockRequest<B> {
/// The ancestor search state expresses which algorithm, and its stateful parameters, we are using to
/// try to find an ancestor block
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum AncestorSearchState<B: Block> {
pub enum AncestorSearchState<B: BlockT> {
/// Use exponential backoff to find an ancestor, then switch to binary search.
/// We keep track of the exponent.
ExponentialBackoff(NumberFor<B>),
@@ -1127,7 +1127,7 @@ pub enum AncestorSearchState<B: Block> {
///
/// When we've found a block hash mismatch we then fall back to a binary search between the two
/// last known points to find the common block closest to the tip.
fn handle_ancestor_search_state<B: Block>(
fn handle_ancestor_search_state<B: BlockT>(
state: &AncestorSearchState<B>,
curr_block_num: NumberFor<B>,
block_hash_match: bool
@@ -1169,7 +1169,7 @@ fn handle_ancestor_search_state<B: Block>(
}
/// Get a new block request for the peer if any.
fn peer_block_request<B: Block>(
fn peer_block_request<B: BlockT>(
id: &PeerId,
peer: &PeerSync<B>,
blocks: &mut BlockCollection<B>,