mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 05:38:00 +00:00
compiles
This commit is contained in:
@@ -20,6 +20,7 @@ use parking_lot::RwLock;
|
||||
use substrate_primitives::AuthorityId;
|
||||
|
||||
use std::cmp::Ord;
|
||||
use std::fmt::Debug;
|
||||
use std::ops::Add;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -54,14 +55,19 @@ impl<H, N> SharedAuthoritySet<H, N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: Eq, N: Add<Output=N> + Ord + Clone> SharedAuthoritySet<H, N> {
|
||||
impl<H: Eq, N> SharedAuthoritySet<H, N>
|
||||
where N: Add<Output=N> + Ord + Clone + Debug
|
||||
{
|
||||
/// Note an upcoming pending transition.
|
||||
pub(crate) fn add_pending_change(&self, pending: PendingChange<H, N>) {
|
||||
// ordered first by effective number and then by signal-block number.
|
||||
let mut inner = self.inner.write();
|
||||
let key = (pending.effective_number(), pending.canon_height);
|
||||
let key = (pending.effective_number(), pending.canon_height.clone());
|
||||
let idx = inner.pending_changes
|
||||
.binary_search_by_key(&key, |change| (change.effective_number(), change.canon_height))
|
||||
.binary_search_by_key(&key, |change| (
|
||||
change.effective_number(),
|
||||
change.canon_height.clone(),
|
||||
))
|
||||
.unwrap_or_else(|i| i);
|
||||
|
||||
inner.pending_changes.insert(idx, pending);
|
||||
@@ -98,11 +104,6 @@ pub(crate) struct AuthoritySet<H, N> {
|
||||
}
|
||||
|
||||
impl<H, N> AuthoritySet<H, N> {
|
||||
/// Get the earliest limit-block number, if any.
|
||||
pub(crate) fn current_limit(&self) -> Option<N> {
|
||||
self.pending_changes.get(0).map(|change| change.effective_number().clone())
|
||||
}
|
||||
|
||||
/// Get the set identifier.
|
||||
pub(crate) fn set_id(&self) -> u64 {
|
||||
self.set_id
|
||||
@@ -114,12 +115,20 @@ impl<H, N> AuthoritySet<H, N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: Eq, N: Ord + Debug> AuthoritySet<H, N> {
|
||||
impl<H: Eq, N> AuthoritySet<H, N>
|
||||
where N: Add<Output=N> + Ord + Clone + Debug,
|
||||
{
|
||||
/// Get the earliest limit-block number, if any.
|
||||
pub(crate) fn current_limit(&self) -> Option<N> {
|
||||
self.pending_changes.get(0).map(|change| change.effective_number().clone())
|
||||
}
|
||||
|
||||
/// Apply or prune any pending transitions. Provide a closure that can be used to check for the
|
||||
/// finalized block with given number.
|
||||
///
|
||||
/// Returns true when the set's representation has changed.
|
||||
pub(crate) fn apply_changes<F, E>(&mut self, just_finalized: N, canonical: F) -> Result<bool, E>
|
||||
pub(crate) fn apply_changes<F, E>(&mut self, just_finalized: N, mut canonical: F)
|
||||
-> Result<bool, E>
|
||||
where F: FnMut(N) -> Result<H, E>
|
||||
{
|
||||
let mut changed = false;
|
||||
@@ -132,7 +141,7 @@ impl<H: Eq, N: Ord + Debug> AuthoritySet<H, N> {
|
||||
|
||||
// check if the block that signalled the change is canonical in
|
||||
// our chain.
|
||||
if canonical(change.canon_height)? == change.canon_hash {
|
||||
if canonical(change.canon_height.clone())? == change.canon_hash {
|
||||
// apply this change: make the set canonical
|
||||
info!(target: "finality", "Applying authority set change scheduled at block #{:?}",
|
||||
change.canon_height);
|
||||
|
||||
@@ -108,7 +108,7 @@ pub enum Error {
|
||||
/// A blockchain error.
|
||||
Blockchain(String),
|
||||
/// Could not complete a round on disk.
|
||||
CouldNotCompleteRound(ClientError),
|
||||
Client(ClientError),
|
||||
/// A timer failed to fire.
|
||||
Timer(::tokio::timer::Error),
|
||||
}
|
||||
@@ -520,7 +520,7 @@ impl From<Error> for ExitOrError {
|
||||
|
||||
impl From<ClientError> for ExitOrError {
|
||||
fn from(e: ClientError) -> Self {
|
||||
ExitOrError::Error(Error::from(e))
|
||||
ExitOrError::Error(Error::Client(e))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ impl<B, E, Block: BlockT, N> voter::Environment<Block::Hash, NumberFor<Block>> f
|
||||
self.config.local_key.clone(),
|
||||
self.config.genesis_voters.clone(),
|
||||
self.network.clone(),
|
||||
).sink_map_err(Into::into);
|
||||
);
|
||||
|
||||
// schedule incoming messages from the network to be held until
|
||||
// corresponding blocks are imported.
|
||||
@@ -595,12 +595,12 @@ impl<B, E, Block: BlockT, N> voter::Environment<Block::Hash, NumberFor<Block>> f
|
||||
let outgoing = Box::new(ClearOnDrop {
|
||||
round,
|
||||
network: self.network.clone(),
|
||||
inner: outgoing,
|
||||
inner: outgoing.sink_map_err(Into::into),
|
||||
});
|
||||
|
||||
voter::RoundData {
|
||||
prevote_timer: Box::new(prevote_timer.map_err(Error::Timer)),
|
||||
precommit_timer: Box::new(precommit_timer.map_err(Error::Timer)),
|
||||
prevote_timer: Box::new(prevote_timer.map_err(|e| Error::Timer(e).into())),
|
||||
precommit_timer: Box::new(precommit_timer.map_err(|e| Error::Timer(e).into())),
|
||||
voters: self.voters.clone(),
|
||||
incoming,
|
||||
outgoing,
|
||||
@@ -613,7 +613,7 @@ impl<B, E, Block: BlockT, N> voter::Environment<Block::Hash, NumberFor<Block>> f
|
||||
.insert_aux(&[(LAST_COMPLETED_KEY, &encoded_state[..])], &[])
|
||||
{
|
||||
warn!(target: "afg", "Shutting down voter due to error bookkeeping last completed round in DB: {:?}", e);
|
||||
Err(Error::CouldNotCompleteRound(e).into())
|
||||
Err(Error::Client(e).into())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user