mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 10:21:05 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -68,7 +68,7 @@ where
|
||||
C: sc_client_api::backend::AuxStore,
|
||||
P::Public: Encode + Decode + PartialEq + Clone,
|
||||
{
|
||||
let seal = header.digest_mut().pop().ok_or_else(|| Error::HeaderUnsealed(hash))?;
|
||||
let seal = header.digest_mut().pop().ok_or(Error::HeaderUnsealed(hash))?;
|
||||
|
||||
let sig = seal.as_aura_seal().ok_or_else(|| aura_err(Error::HeaderBadSeal(hash)))?;
|
||||
|
||||
@@ -81,7 +81,7 @@ where
|
||||
// check the signature is valid under the expected authority and
|
||||
// chain state.
|
||||
let expected_author =
|
||||
slot_author::<P>(slot, &authorities).ok_or_else(|| Error::SlotAuthorNotFound)?;
|
||||
slot_author::<P>(slot, authorities).ok_or(Error::SlotAuthorNotFound)?;
|
||||
|
||||
let pre_hash = header.hash();
|
||||
|
||||
@@ -360,7 +360,7 @@ pub struct ImportQueueParams<'a, Block, I, C, S, CAW, CIDP> {
|
||||
}
|
||||
|
||||
/// Start an import queue for the Aura consensus algorithm.
|
||||
pub fn import_queue<'a, P, Block, I, C, S, CAW, CIDP>(
|
||||
pub fn import_queue<P, Block, I, C, S, CAW, CIDP>(
|
||||
ImportQueueParams {
|
||||
block_import,
|
||||
justification_import,
|
||||
@@ -371,7 +371,7 @@ pub fn import_queue<'a, P, Block, I, C, S, CAW, CIDP>(
|
||||
can_author_with,
|
||||
check_for_equivocation,
|
||||
telemetry,
|
||||
}: ImportQueueParams<'a, Block, I, C, S, CAW, CIDP>,
|
||||
}: ImportQueueParams<Block, I, C, S, CAW, CIDP>,
|
||||
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
|
||||
where
|
||||
Block: BlockT,
|
||||
|
||||
@@ -186,7 +186,7 @@ where
|
||||
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
|
||||
{
|
||||
let worker = build_aura_worker::<P, _, _, _, _, _, _, _, _>(BuildAuraWorkerParams {
|
||||
client: client.clone(),
|
||||
client,
|
||||
block_import,
|
||||
proposer_factory,
|
||||
keystore,
|
||||
@@ -459,7 +459,7 @@ where
|
||||
fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer {
|
||||
self.env
|
||||
.init(block)
|
||||
.map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e)).into())
|
||||
.map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e)))
|
||||
.boxed()
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ pub fn find_pre_digest<B: BlockT, Signature: Codec>(header: &B::Header) -> Resul
|
||||
for log in header.digest().logs() {
|
||||
trace!(target: "aura", "Checking log {:?}", log);
|
||||
match (CompatibleDigestItem::<Signature>::as_aura_pre_digest(log), pre_digest.is_some()) {
|
||||
(Some(_), true) => Err(aura_err(Error::MultipleHeaders))?,
|
||||
(Some(_), true) => return Err(aura_err(Error::MultipleHeaders)),
|
||||
(None, _) => trace!(target: "aura", "Ignoring digest not meant for us"),
|
||||
(s, false) => pre_digest = s,
|
||||
}
|
||||
@@ -553,7 +553,7 @@ where
|
||||
.runtime_api()
|
||||
.authorities(at)
|
||||
.ok()
|
||||
.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet.into())
|
||||
.ok_or(sp_consensus::Error::InvalidAuthoritiesSet)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -142,7 +142,7 @@ where
|
||||
claims.entry(key).or_default().secondary.push(slot);
|
||||
},
|
||||
PreDigest::SecondaryVRF { .. } => {
|
||||
claims.entry(key).or_default().secondary_vrf.push(slot.into());
|
||||
claims.entry(key).or_default().secondary_vrf.push(slot);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -205,7 +205,7 @@ where
|
||||
.epoch_data_for_child_of(
|
||||
descendent_query(&**client),
|
||||
&parent.hash(),
|
||||
parent.number().clone(),
|
||||
*parent.number(),
|
||||
slot.into(),
|
||||
|slot| Epoch::genesis(babe_config.genesis_config(), slot),
|
||||
)
|
||||
|
||||
@@ -202,15 +202,15 @@ pub fn claim_slot_using_keys(
|
||||
keystore: &SyncCryptoStorePtr,
|
||||
keys: &[(AuthorityId, usize)],
|
||||
) -> Option<(PreDigest, AuthorityId)> {
|
||||
claim_primary_slot(slot, epoch, epoch.config.c, keystore, &keys).or_else(|| {
|
||||
claim_primary_slot(slot, epoch, epoch.config.c, keystore, keys).or_else(|| {
|
||||
if epoch.config.allowed_slots.is_secondary_plain_slots_allowed() ||
|
||||
epoch.config.allowed_slots.is_secondary_vrf_slots_allowed()
|
||||
{
|
||||
claim_secondary_slot(
|
||||
slot,
|
||||
&epoch,
|
||||
epoch,
|
||||
keys,
|
||||
&keystore,
|
||||
keystore,
|
||||
epoch.config.allowed_slots.is_secondary_vrf_slots_allowed(),
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -528,7 +528,7 @@ where
|
||||
let (worker_tx, worker_rx) = channel(HANDLE_BUFFER_SIZE);
|
||||
|
||||
let answer_requests =
|
||||
answer_requests(worker_rx, babe_link.config, client, babe_link.epoch_changes.clone());
|
||||
answer_requests(worker_rx, babe_link.config, client, babe_link.epoch_changes);
|
||||
|
||||
let inner = future::select(Box::pin(slot_worker), Box::pin(answer_requests));
|
||||
Ok(BabeWorker {
|
||||
@@ -638,13 +638,13 @@ async fn answer_requests<B: BlockT, C>(
|
||||
slot_number,
|
||||
)
|
||||
.map_err(|e| Error::<B>::ForkTree(Box::new(e)))?
|
||||
.ok_or_else(|| Error::<B>::FetchEpoch(parent_hash))?;
|
||||
.ok_or(Error::<B>::FetchEpoch(parent_hash))?;
|
||||
|
||||
let viable_epoch = epoch_changes
|
||||
.viable_epoch(&epoch_descriptor, |slot| {
|
||||
Epoch::genesis(&config.genesis_config, slot)
|
||||
})
|
||||
.ok_or_else(|| Error::<B>::FetchEpoch(parent_hash))?;
|
||||
.ok_or(Error::<B>::FetchEpoch(parent_hash))?;
|
||||
|
||||
Ok(sp_consensus_babe::Epoch {
|
||||
epoch_index: viable_epoch.as_ref().epoch_index,
|
||||
@@ -788,7 +788,7 @@ where
|
||||
.epoch_descriptor_for_child_of(
|
||||
descendent_query(&*self.client),
|
||||
&parent.hash(),
|
||||
parent.number().clone(),
|
||||
*parent.number(),
|
||||
slot,
|
||||
)
|
||||
.map_err(|e| ConsensusError::ChainLookup(e.to_string()))?
|
||||
@@ -798,7 +798,7 @@ where
|
||||
fn authorities_len(&self, epoch_descriptor: &Self::EpochData) -> Option<usize> {
|
||||
self.epoch_changes
|
||||
.shared_data()
|
||||
.viable_epoch(&epoch_descriptor, |slot| {
|
||||
.viable_epoch(epoch_descriptor, |slot| {
|
||||
Epoch::genesis(&self.config.genesis_config, slot)
|
||||
})
|
||||
.map(|epoch| epoch.as_ref().authorities.len())
|
||||
@@ -815,7 +815,7 @@ where
|
||||
slot,
|
||||
self.epoch_changes
|
||||
.shared_data()
|
||||
.viable_epoch(&epoch_descriptor, |slot| {
|
||||
.viable_epoch(epoch_descriptor, |slot| {
|
||||
Epoch::genesis(&self.config.genesis_config, slot)
|
||||
})?
|
||||
.as_ref(),
|
||||
@@ -886,7 +886,7 @@ where
|
||||
.clone()
|
||||
.try_into()
|
||||
.map_err(|_| sp_consensus::Error::InvalidSignature(signature, public))?;
|
||||
let digest_item = <DigestItem as CompatibleDigestItem>::babe_seal(signature.into());
|
||||
let digest_item = <DigestItem as CompatibleDigestItem>::babe_seal(signature);
|
||||
|
||||
let mut import_block = BlockImportParams::new(BlockOrigin::Own, header);
|
||||
import_block.post_digests.push(digest_item);
|
||||
@@ -1245,12 +1245,12 @@ where
|
||||
pre_digest.slot(),
|
||||
)
|
||||
.map_err(|e| Error::<Block>::ForkTree(Box::new(e)))?
|
||||
.ok_or_else(|| Error::<Block>::FetchEpoch(parent_hash))?;
|
||||
.ok_or(Error::<Block>::FetchEpoch(parent_hash))?;
|
||||
let viable_epoch = epoch_changes
|
||||
.viable_epoch(&epoch_descriptor, |slot| {
|
||||
Epoch::genesis(&self.config.genesis_config, slot)
|
||||
})
|
||||
.ok_or_else(|| Error::<Block>::FetchEpoch(parent_hash))?;
|
||||
.ok_or(Error::<Block>::FetchEpoch(parent_hash))?;
|
||||
|
||||
// We add one to the current slot to allow for some small drift.
|
||||
// FIXME #1019 in the future, alter this queue to allow deferring of headers
|
||||
|
||||
@@ -99,7 +99,7 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
primary.slot,
|
||||
);
|
||||
|
||||
check_primary_header::<B>(pre_hash, primary, sig, &epoch, epoch.config.c)?;
|
||||
check_primary_header::<B>(pre_hash, primary, sig, epoch, epoch.config.c)?;
|
||||
},
|
||||
PreDigest::SecondaryPlain(secondary)
|
||||
if epoch.config.allowed_slots.is_secondary_plain_slots_allowed() =>
|
||||
@@ -110,7 +110,7 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
secondary.slot,
|
||||
);
|
||||
|
||||
check_secondary_plain_header::<B>(pre_hash, secondary, sig, &epoch)?;
|
||||
check_secondary_plain_header::<B>(pre_hash, secondary, sig, epoch)?;
|
||||
},
|
||||
PreDigest::SecondaryVRF(secondary)
|
||||
if epoch.config.allowed_slots.is_secondary_vrf_slots_allowed() =>
|
||||
@@ -121,7 +121,7 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
||||
secondary.slot,
|
||||
);
|
||||
|
||||
check_secondary_vrf_header::<B>(pre_hash, secondary, sig, &epoch)?;
|
||||
check_secondary_vrf_header::<B>(pre_hash, secondary, sig, epoch)?;
|
||||
},
|
||||
_ => return Err(babe_err(Error::SecondarySlotAssignmentsDisabled)),
|
||||
}
|
||||
@@ -153,7 +153,7 @@ fn check_primary_header<B: BlockT + Sized>(
|
||||
) -> Result<(), Error<B>> {
|
||||
let author = &epoch.authorities[pre_digest.authority_index as usize].0;
|
||||
|
||||
if AuthorityPair::verify(&signature, pre_hash, &author) {
|
||||
if AuthorityPair::verify(&signature, pre_hash, author) {
|
||||
let (inout, _) = {
|
||||
let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch.epoch_index);
|
||||
|
||||
@@ -191,7 +191,7 @@ fn check_secondary_plain_header<B: BlockT>(
|
||||
// chain state.
|
||||
let expected_author =
|
||||
secondary_slot_author(pre_digest.slot, &epoch.authorities, epoch.randomness)
|
||||
.ok_or_else(|| Error::NoSecondaryAuthorExpected)?;
|
||||
.ok_or(Error::NoSecondaryAuthorExpected)?;
|
||||
|
||||
let author = &epoch.authorities[pre_digest.authority_index as usize].0;
|
||||
|
||||
@@ -217,7 +217,7 @@ fn check_secondary_vrf_header<B: BlockT>(
|
||||
// chain state.
|
||||
let expected_author =
|
||||
secondary_slot_author(pre_digest.slot, &epoch.authorities, epoch.randomness)
|
||||
.ok_or_else(|| Error::NoSecondaryAuthorExpected)?;
|
||||
.ok_or(Error::NoSecondaryAuthorExpected)?;
|
||||
|
||||
let author = &epoch.authorities[pre_digest.authority_index as usize].0;
|
||||
|
||||
|
||||
@@ -62,8 +62,7 @@ impl ImportResult {
|
||||
/// `clear_justification_requests`, `needs_justification`,
|
||||
/// `bad_justification` set to false.
|
||||
pub fn imported(is_new_best: bool) -> ImportResult {
|
||||
let mut aux = ImportedAux::default();
|
||||
aux.is_new_best = is_new_best;
|
||||
let aux = ImportedAux { is_new_best, ..Default::default() };
|
||||
|
||||
ImportResult::Imported(aux)
|
||||
}
|
||||
|
||||
@@ -232,17 +232,17 @@ pub(crate) async fn import_single_block_metered<
|
||||
|
||||
trace!(target: "sync", "Header {} has {:?} logs", block.hash, header.digest().logs().len());
|
||||
|
||||
let number = header.number().clone();
|
||||
let number = *header.number();
|
||||
let hash = block.hash;
|
||||
let parent_hash = header.parent_hash().clone();
|
||||
let parent_hash = *header.parent_hash();
|
||||
|
||||
let import_handler = |import| match import {
|
||||
Ok(ImportResult::AlreadyInChain) => {
|
||||
trace!(target: "sync", "Block already in chain {}: {:?}", number, hash);
|
||||
Ok(BlockImportStatus::ImportedKnown(number, peer.clone()))
|
||||
Ok(BlockImportStatus::ImportedKnown(number, peer))
|
||||
},
|
||||
Ok(ImportResult::Imported(aux)) =>
|
||||
Ok(BlockImportStatus::ImportedUnknown(number, aux, peer.clone())),
|
||||
Ok(BlockImportStatus::ImportedUnknown(number, aux, peer)),
|
||||
Ok(ImportResult::MissingState) => {
|
||||
debug!(target: "sync", "Parent state is missing for {}: {:?}, parent: {:?}",
|
||||
number, hash, parent_hash);
|
||||
@@ -255,7 +255,7 @@ pub(crate) async fn import_single_block_metered<
|
||||
},
|
||||
Ok(ImportResult::KnownBad) => {
|
||||
debug!(target: "sync", "Peer gave us a bad block {}: {:?}", number, hash);
|
||||
Err(BlockImportError::BadBlock(peer.clone()))
|
||||
Err(BlockImportError::BadBlock(peer))
|
||||
},
|
||||
Err(e) => {
|
||||
debug!(target: "sync", "Error importing block {}: {:?}: {}", number, hash, e);
|
||||
@@ -306,7 +306,7 @@ pub(crate) async fn import_single_block_metered<
|
||||
if let Some(metrics) = metrics.as_ref() {
|
||||
metrics.report_verification(false, started.elapsed());
|
||||
}
|
||||
BlockImportError::VerificationFailed(peer.clone(), msg)
|
||||
BlockImportError::VerificationFailed(peer, msg)
|
||||
})?;
|
||||
|
||||
if let Some(metrics) = metrics.as_ref() {
|
||||
|
||||
@@ -374,7 +374,7 @@ async fn import_many_blocks<B: BlockT, V: Verifier<B>, Transaction: Send + 'stat
|
||||
},
|
||||
};
|
||||
|
||||
let block_number = block.header.as_ref().map(|h| h.number().clone());
|
||||
let block_number = block.header.as_ref().map(|h| *h.number());
|
||||
let block_hash = block.hash;
|
||||
let import_result = if has_error {
|
||||
Err(BlockImportError::Cancelled)
|
||||
@@ -382,7 +382,7 @@ async fn import_many_blocks<B: BlockT, V: Verifier<B>, Transaction: Send + 'stat
|
||||
// The actual import.
|
||||
import_single_block_metered(
|
||||
import_handle,
|
||||
blocks_origin.clone(),
|
||||
blocks_origin,
|
||||
block,
|
||||
verifier,
|
||||
metrics.clone(),
|
||||
|
||||
@@ -105,14 +105,14 @@ impl<B: BlockT> Link<B> for BufferedLinkSender<B> {
|
||||
number: NumberFor<B>,
|
||||
success: bool,
|
||||
) {
|
||||
let msg = BlockImportWorkerMsg::JustificationImported(who, hash.clone(), number, success);
|
||||
let msg = BlockImportWorkerMsg::JustificationImported(who, *hash, number, success);
|
||||
let _ = self.tx.unbounded_send(msg);
|
||||
}
|
||||
|
||||
fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>) {
|
||||
let _ = self
|
||||
.tx
|
||||
.unbounded_send(BlockImportWorkerMsg::RequestJustification(hash.clone(), number));
|
||||
.unbounded_send(BlockImportWorkerMsg::RequestJustification(*hash, number));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +79,12 @@ where
|
||||
Block: BlockT,
|
||||
{
|
||||
async fn leaves(&self) -> Result<Vec<<Block as BlockT>::Hash>, ConsensusError> {
|
||||
LongestChain::leaves(self).map_err(|e| ConsensusError::ChainLookup(e.to_string()).into())
|
||||
LongestChain::leaves(self).map_err(|e| ConsensusError::ChainLookup(e.to_string()))
|
||||
}
|
||||
|
||||
async fn best_chain(&self) -> Result<<Block as BlockT>::Header, ConsensusError> {
|
||||
LongestChain::best_block_header(&self)
|
||||
.map_err(|e| ConsensusError::ChainLookup(e.to_string()).into())
|
||||
LongestChain::best_block_header(self)
|
||||
.map_err(|e| ConsensusError::ChainLookup(e.to_string()))
|
||||
}
|
||||
|
||||
async fn finality_target(
|
||||
@@ -97,6 +97,6 @@ where
|
||||
.blockchain()
|
||||
.best_containing(target_hash, maybe_max_number, import_lock)
|
||||
.map(|maybe_hash| maybe_hash.unwrap_or(target_hash))
|
||||
.map_err(|e| ConsensusError::ChainLookup(e.to_string()).into())
|
||||
.map_err(|e| ConsensusError::ChainLookup(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ where
|
||||
ViableEpochDescriptor::UnimportedGenesis(slot) =>
|
||||
Some(ViableEpoch::UnimportedGenesis(make_genesis(*slot))),
|
||||
ViableEpochDescriptor::Signaled(identifier, _) =>
|
||||
self.epoch(&identifier).map(ViableEpoch::Signaled),
|
||||
self.epoch(identifier).map(ViableEpoch::Signaled),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ where
|
||||
ViableEpochDescriptor::UnimportedGenesis(slot) =>
|
||||
Some(ViableEpoch::UnimportedGenesis(make_genesis(*slot))),
|
||||
ViableEpochDescriptor::Signaled(identifier, _) =>
|
||||
self.epoch_mut(&identifier).map(ViableEpoch::Signaled),
|
||||
self.epoch_mut(identifier).map(ViableEpoch::Signaled),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ where
|
||||
{
|
||||
match descriptor {
|
||||
ViableEpochDescriptor::UnimportedGenesis(slot) => Some(make_genesis(*slot)),
|
||||
ViableEpochDescriptor::Signaled(identifier, _) => self.epoch(&identifier).cloned(),
|
||||
ViableEpochDescriptor::Signaled(identifier, _) => self.epoch(identifier).cloned(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ where
|
||||
|
||||
if let Some(gap) = &mut self.gap {
|
||||
if let PersistedEpoch::Regular(e) = epoch {
|
||||
epoch = match gap.import(slot, hash.clone(), number.clone(), e) {
|
||||
epoch = match gap.import(slot, hash, number, e) {
|
||||
Ok(()) => return Ok(()),
|
||||
Err(e) => PersistedEpoch::Regular(e),
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ where
|
||||
.epoch_descriptor_for_child_of(
|
||||
descendent_query(&*self.client),
|
||||
&parent.hash(),
|
||||
parent.number().clone(),
|
||||
*parent.number(),
|
||||
pre_digest.slot(),
|
||||
)
|
||||
.map_err(|e| format!("failed to fetch epoch_descriptor: {}", e))?
|
||||
@@ -162,11 +162,11 @@ where
|
||||
.epoch_descriptor_for_child_of(
|
||||
descendent_query(&*self.client),
|
||||
&parent.hash(),
|
||||
parent.number().clone(),
|
||||
*parent.number(),
|
||||
slot,
|
||||
)
|
||||
.map_err(|e| Error::StringError(format!("failed to fetch epoch_descriptor: {}", e)))?
|
||||
.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
.ok_or(sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
|
||||
let epoch = epoch_changes
|
||||
.viable_epoch(&epoch_descriptor, |slot| {
|
||||
@@ -216,19 +216,19 @@ where
|
||||
.epoch_descriptor_for_child_of(
|
||||
descendent_query(&*self.client),
|
||||
&parent.hash(),
|
||||
parent.number().clone(),
|
||||
*parent.number(),
|
||||
slot,
|
||||
)
|
||||
.map_err(|e| {
|
||||
Error::StringError(format!("failed to fetch epoch_descriptor: {}", e))
|
||||
})?
|
||||
.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
.ok_or(sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
|
||||
match epoch_descriptor {
|
||||
ViableEpochDescriptor::Signaled(identifier, _epoch_header) => {
|
||||
let epoch_mut = epoch_changes
|
||||
.epoch_mut(&identifier)
|
||||
.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
.ok_or(sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
|
||||
// mutate the current epoch
|
||||
epoch_mut.authorities = self.authorities.clone();
|
||||
@@ -236,7 +236,7 @@ where
|
||||
let next_epoch = ConsensusLog::NextEpochData(NextEpochDescriptor {
|
||||
authorities: self.authorities.clone(),
|
||||
// copy the old randomness
|
||||
randomness: epoch_mut.randomness.clone(),
|
||||
randomness: epoch_mut.randomness,
|
||||
});
|
||||
|
||||
vec![
|
||||
@@ -268,11 +268,11 @@ where
|
||||
.epoch_descriptor_for_child_of(
|
||||
descendent_query(&*self.client),
|
||||
&parent.hash(),
|
||||
parent.number().clone(),
|
||||
*parent.number(),
|
||||
slot,
|
||||
)
|
||||
.map_err(|e| Error::StringError(format!("failed to fetch epoch_descriptor: {}", e)))?
|
||||
.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
.ok_or(sp_consensus::Error::InvalidAuthoritiesSet)?;
|
||||
// drop the lock
|
||||
drop(epoch_changes);
|
||||
// a quick check to see if we're in the authorities
|
||||
|
||||
@@ -234,7 +234,7 @@ impl<B: BlockT, I: Clone, C, S: Clone, Algorithm: Clone, CAW: Clone, CIDP> Clone
|
||||
select_chain: self.select_chain.clone(),
|
||||
client: self.client.clone(),
|
||||
create_inherent_data_providers: self.create_inherent_data_providers.clone(),
|
||||
check_inherents_after: self.check_inherents_after.clone(),
|
||||
check_inherents_after: self.check_inherents_after,
|
||||
can_author_with: self.can_author_with.clone(),
|
||||
}
|
||||
}
|
||||
@@ -652,21 +652,19 @@ where
|
||||
},
|
||||
};
|
||||
|
||||
let proposal = match proposer
|
||||
.propose(inherent_data, inherent_digest, build_time.clone(), None)
|
||||
.await
|
||||
{
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to propose new block for authoring. \
|
||||
Creating proposal failed: {}",
|
||||
err,
|
||||
);
|
||||
continue
|
||||
},
|
||||
};
|
||||
let proposal =
|
||||
match proposer.propose(inherent_data, inherent_digest, build_time, None).await {
|
||||
Ok(x) => x,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
target: "pow",
|
||||
"Unable to propose new block for authoring. \
|
||||
Creating proposal failed: {}",
|
||||
err,
|
||||
);
|
||||
continue
|
||||
},
|
||||
};
|
||||
|
||||
let build = MiningBuild::<Block, Algorithm, C, _> {
|
||||
metadata: MiningMetadata {
|
||||
@@ -710,8 +708,8 @@ fn fetch_seal<B: BlockT>(digest: Option<&DigestItem>, hash: B::Hash) -> Result<V
|
||||
if id == &POW_ENGINE_ID {
|
||||
Ok(seal.clone())
|
||||
} else {
|
||||
return Err(Error::<B>::WrongEngine(*id).into())
|
||||
Err(Error::<B>::WrongEngine(*id))
|
||||
},
|
||||
_ => return Err(Error::<B>::HeaderUnsealed(hash).into()),
|
||||
_ => Err(Error::<B>::HeaderUnsealed(hash)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ impl<Block: BlockT> Stream for UntilImportedOrTimeout<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
let timeout = self.timeout.clone();
|
||||
let timeout = self.timeout;
|
||||
let inner_delay = self.inner_delay.get_or_insert_with(|| Delay::new(timeout));
|
||||
|
||||
match Future::poll(Pin::new(inner_delay), cx) {
|
||||
|
||||
@@ -63,7 +63,7 @@ where
|
||||
P: Clone + Encode + Decode + PartialEq,
|
||||
{
|
||||
// We don't check equivocations for old headers out of our capacity.
|
||||
if slot_now.saturating_sub(*slot) > Slot::from(MAX_SLOT_CAPACITY) {
|
||||
if slot_now.saturating_sub(*slot) > MAX_SLOT_CAPACITY {
|
||||
return Ok(None)
|
||||
}
|
||||
|
||||
|
||||
@@ -606,7 +606,7 @@ pub fn proposing_remaining_duration<Block: BlockT>(
|
||||
// if we defined a maximum portion of the slot for proposal then we must make sure the
|
||||
// lenience doesn't go over it
|
||||
let lenient_proposing_duration =
|
||||
if let Some(ref max_block_proposal_slot_portion) = max_block_proposal_slot_portion {
|
||||
if let Some(max_block_proposal_slot_portion) = max_block_proposal_slot_portion {
|
||||
std::cmp::min(
|
||||
lenient_proposing_duration,
|
||||
slot_info.duration.mul_f32(max_block_proposal_slot_portion.get()),
|
||||
|
||||
Reference in New Issue
Block a user