mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 21:31:02 +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
@@ -88,10 +88,10 @@ impl RoundState {
|
||||
voters: &HashSet<AuthorityId>,
|
||||
) -> Result<Self, Error> {
|
||||
let prevotes = &round_state.prevote_ids;
|
||||
let missing_prevotes = voters.difference(&prevotes).cloned().collect();
|
||||
let missing_prevotes = voters.difference(prevotes).cloned().collect();
|
||||
|
||||
let precommits = &round_state.precommit_ids;
|
||||
let missing_precommits = voters.difference(&precommits).cloned().collect();
|
||||
let missing_precommits = voters.difference(precommits).cloned().collect();
|
||||
|
||||
Ok(Self {
|
||||
round: round.try_into()?,
|
||||
|
||||
@@ -557,8 +557,7 @@ where
|
||||
fork_tree::FinalizationResult::Changed(change) => {
|
||||
status.changed = true;
|
||||
|
||||
let pending_forced_changes =
|
||||
std::mem::replace(&mut self.pending_forced_changes, Vec::new());
|
||||
let pending_forced_changes = std::mem::take(&mut self.pending_forced_changes);
|
||||
|
||||
// we will keep all forced changes for any later blocks and that are a
|
||||
// descendent of the finalized block (i.e. they are part of this branch).
|
||||
|
||||
@@ -430,7 +430,7 @@ where
|
||||
// reset.
|
||||
let set_state = VoterSetState::<Block>::live(
|
||||
new_set.set_id,
|
||||
&set,
|
||||
set,
|
||||
(new_set.canon_hash, new_set.canon_number),
|
||||
);
|
||||
let encoded = set_state.encode();
|
||||
|
||||
@@ -504,13 +504,13 @@ impl<N: Ord> Peers<N> {
|
||||
fn new_peer(&mut self, who: PeerId, role: ObservedRole) {
|
||||
match role {
|
||||
ObservedRole::Authority if self.first_stage_peers.len() < LUCKY_PEERS => {
|
||||
self.first_stage_peers.insert(who.clone());
|
||||
self.first_stage_peers.insert(who);
|
||||
},
|
||||
ObservedRole::Authority if self.second_stage_peers.len() < LUCKY_PEERS => {
|
||||
self.second_stage_peers.insert(who.clone());
|
||||
self.second_stage_peers.insert(who);
|
||||
},
|
||||
ObservedRole::Light if self.lucky_light_peers.len() < LUCKY_PEERS => {
|
||||
self.lucky_light_peers.insert(who.clone());
|
||||
self.lucky_light_peers.insert(who);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
@@ -590,11 +590,8 @@ impl<N: Ord> Peers<N> {
|
||||
// - third set: LUCKY_PEERS random light client peers
|
||||
|
||||
let shuffled_peers = {
|
||||
let mut peers = self
|
||||
.inner
|
||||
.iter()
|
||||
.map(|(peer_id, info)| (*peer_id, info.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
let mut peers =
|
||||
self.inner.iter().map(|(peer_id, info)| (*peer_id, info)).collect::<Vec<_>>();
|
||||
|
||||
peers.shuffle(&mut rand::thread_rng());
|
||||
peers
|
||||
@@ -1103,7 +1100,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
// won't be able to reply since they don't follow the full GRANDPA
|
||||
// protocol and therefore might not have the vote data available.
|
||||
if let (Some(peer), Some(local_view)) = (self.peers.peer(who), &self.local_view) {
|
||||
if self.catch_up_config.request_allowed(&peer) &&
|
||||
if self.catch_up_config.request_allowed(peer) &&
|
||||
peer.view.set_id == local_view.set_id &&
|
||||
peer.view.round.0.saturating_sub(CATCH_UP_THRESHOLD) > local_view.round.0
|
||||
{
|
||||
@@ -1195,7 +1192,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
return (false, None)
|
||||
} else {
|
||||
// report peer for timeout
|
||||
Some((peer.clone(), cost::CATCH_UP_REQUEST_TIMEOUT))
|
||||
Some((*peer, cost::CATCH_UP_REQUEST_TIMEOUT))
|
||||
}
|
||||
},
|
||||
PendingCatchUp::Processing { instant, .. } => {
|
||||
@@ -1209,7 +1206,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
};
|
||||
|
||||
self.pending_catch_up = PendingCatchUp::Requesting {
|
||||
who: who.clone(),
|
||||
who: *who,
|
||||
request: catch_up_request.clone(),
|
||||
instant: Instant::now(),
|
||||
};
|
||||
@@ -1488,7 +1485,7 @@ impl<Block: BlockT> sc_network_gossip::Validator<Block> for GossipValidator<Bloc
|
||||
) {
|
||||
let packet = {
|
||||
let mut inner = self.inner.write();
|
||||
inner.peers.new_peer(who.clone(), roles);
|
||||
inner.peers.new_peer(*who, roles);
|
||||
|
||||
inner.local_view.as_ref().map(|v| NeighborPacket {
|
||||
round: v.round,
|
||||
@@ -1526,16 +1523,16 @@ impl<Block: BlockT> sc_network_gossip::Validator<Block> for GossipValidator<Bloc
|
||||
|
||||
match action {
|
||||
Action::Keep(topic, cb) => {
|
||||
self.report(who.clone(), cb);
|
||||
self.report(*who, cb);
|
||||
context.broadcast_message(topic, data.to_vec(), false);
|
||||
sc_network_gossip::ValidationResult::ProcessAndKeep(topic)
|
||||
},
|
||||
Action::ProcessAndDiscard(topic, cb) => {
|
||||
self.report(who.clone(), cb);
|
||||
self.report(*who, cb);
|
||||
sc_network_gossip::ValidationResult::ProcessAndDiscard(topic)
|
||||
},
|
||||
Action::Discard(cb) => {
|
||||
self.report(who.clone(), cb);
|
||||
self.report(*who, cb);
|
||||
sc_network_gossip::ValidationResult::Discard
|
||||
},
|
||||
}
|
||||
@@ -1572,7 +1569,7 @@ impl<Block: BlockT> sc_network_gossip::Validator<Block> for GossipValidator<Bloc
|
||||
|
||||
// if the topic is not something we're keeping at the moment,
|
||||
// do not send.
|
||||
let (maybe_round, set_id) = match inner.live_topics.topic_info(&topic) {
|
||||
let (maybe_round, set_id) = match inner.live_topics.topic_info(topic) {
|
||||
None => return false,
|
||||
Some(x) => x,
|
||||
};
|
||||
@@ -1583,11 +1580,9 @@ impl<Block: BlockT> sc_network_gossip::Validator<Block> for GossipValidator<Bloc
|
||||
// early return if the vote message isn't allowed at this stage.
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if !inner.global_message_allowed(who) {
|
||||
// early return if the global message isn't allowed at this stage.
|
||||
return false
|
||||
}
|
||||
} else if !inner.global_message_allowed(who) {
|
||||
// early return if the global message isn't allowed at this stage.
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ pub(crate) mod tests;
|
||||
pub mod grandpa_protocol_name {
|
||||
use sc_chain_spec::ChainSpec;
|
||||
|
||||
pub(crate) const NAME: &'static str = "/grandpa/1";
|
||||
pub(crate) const NAME: &str = "/grandpa/1";
|
||||
/// Old names for the notifications protocol, used for backward compatibility.
|
||||
pub(crate) const LEGACY_NAMES: [&'static str; 1] = ["/paritytech/grandpa/1"];
|
||||
pub(crate) const LEGACY_NAMES: [&str; 1] = ["/paritytech/grandpa/1"];
|
||||
|
||||
/// Name of the notifications protocol used by GRANDPA.
|
||||
///
|
||||
@@ -876,7 +876,7 @@ fn check_catch_up<Block: BlockT>(
|
||||
let mut total_weight = 0;
|
||||
|
||||
for id in votes {
|
||||
if let Some(weight) = voters.get(&id).map(|info| info.weight()) {
|
||||
if let Some(weight) = voters.get(id).map(|info| info.weight()) {
|
||||
total_weight += weight.get();
|
||||
if total_weight > full_threshold {
|
||||
return Err(cost::MALFORMED_CATCH_UP)
|
||||
|
||||
@@ -451,7 +451,7 @@ impl<BE, Block: BlockT, C, N: NetworkT<Block>, SC, VR> Environment<BE, Block, C,
|
||||
F: FnOnce(&VoterSetState<Block>) -> Result<Option<VoterSetState<Block>>, Error>,
|
||||
{
|
||||
self.voter_set_state.with(|voter_set_state| {
|
||||
if let Some(set_state) = f(&voter_set_state)? {
|
||||
if let Some(set_state) = f(voter_set_state)? {
|
||||
*voter_set_state = set_state;
|
||||
|
||||
if let Some(metrics) = self.metrics.as_ref() {
|
||||
@@ -987,11 +987,9 @@ where
|
||||
let mut current_rounds = current_rounds.clone();
|
||||
current_rounds.remove(&round);
|
||||
|
||||
// NOTE: this condition should always hold as GRANDPA rounds are always
|
||||
// NOTE: this entry should always exist as GRANDPA rounds are always
|
||||
// started in increasing order, still it's better to play it safe.
|
||||
if !current_rounds.contains_key(&(round + 1)) {
|
||||
current_rounds.insert(round + 1, HasVoted::No);
|
||||
}
|
||||
current_rounds.entry(round + 1).or_insert(HasVoted::No);
|
||||
|
||||
let set_state = VoterSetState::<Block>::Live { completed_rounds, current_rounds };
|
||||
|
||||
@@ -1046,7 +1044,7 @@ where
|
||||
.votes
|
||||
.extend(historical_votes.seen().iter().skip(n_existing_votes).cloned());
|
||||
already_completed.state = state;
|
||||
crate::aux_schema::write_concluded_round(&*self.client, &already_completed)?;
|
||||
crate::aux_schema::write_concluded_round(&*self.client, already_completed)?;
|
||||
}
|
||||
|
||||
let set_state = VoterSetState::<Block>::Live {
|
||||
|
||||
@@ -439,8 +439,7 @@ where
|
||||
// This code may be removed once warp sync to an old runtime is no longer needed.
|
||||
for prefix in ["GrandpaFinality", "Grandpa"] {
|
||||
let k = [twox_128(prefix.as_bytes()), twox_128(b"CurrentSetId")].concat();
|
||||
if let Ok(Some(id)) =
|
||||
self.inner.storage(&id, &sc_client_api::StorageKey(k.to_vec()))
|
||||
if let Ok(Some(id)) = self.inner.storage(id, &sc_client_api::StorageKey(k.to_vec()))
|
||||
{
|
||||
if let Ok(id) = SetId::decode(&mut id.0.as_ref()) {
|
||||
return Ok(id)
|
||||
@@ -451,7 +450,7 @@ where
|
||||
} else {
|
||||
self.inner
|
||||
.runtime_api()
|
||||
.current_set_id(&id)
|
||||
.current_set_id(id)
|
||||
.map_err(|e| ConsensusError::ClientImport(e.to_string()))
|
||||
}
|
||||
}
|
||||
@@ -732,7 +731,7 @@ impl<Backend, Block: BlockT, Client, SC> GrandpaBlockImport<Backend, Block, Clie
|
||||
|
||||
authority_set.pending_standard_changes =
|
||||
authority_set.pending_standard_changes.clone().map(&mut |hash, _, original| {
|
||||
authority_set_hard_forks.get(&hash).cloned().unwrap_or(original)
|
||||
authority_set_hard_forks.get(hash).cloned().unwrap_or(original)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ where
|
||||
base: Block::Hash,
|
||||
block: Block::Hash,
|
||||
) -> Result<Vec<Block::Hash>, GrandpaError> {
|
||||
environment::ancestry(&self.client, base, block)
|
||||
environment::ancestry(self.client, base, block)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,13 +193,13 @@ where
|
||||
);
|
||||
|
||||
let observer_work = ObserverWork::new(
|
||||
client.clone(),
|
||||
client,
|
||||
network,
|
||||
persistent_data,
|
||||
config.keystore,
|
||||
voter_commands_rx,
|
||||
Some(justification_sender),
|
||||
telemetry.clone(),
|
||||
telemetry,
|
||||
);
|
||||
|
||||
let observer_work = observer_work.map_ok(|_| ()).map_err(|e| {
|
||||
|
||||
@@ -125,7 +125,7 @@ where
|
||||
let current_target = current_target.clone();
|
||||
|
||||
// find the block at the given target height
|
||||
Box::pin(std::future::ready(find_target(&*backend, target_number.clone(), ¤t_target)))
|
||||
Box::pin(std::future::ready(find_target(&*backend, target_number, ¤t_target)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ impl<Block: BlockT> WarpSyncProof<Block> {
|
||||
let hash = proof.header.hash();
|
||||
let number = *proof.header.number();
|
||||
|
||||
if let Some((set_id, list)) = hard_forks.get(&(hash.clone(), number)) {
|
||||
if let Some((set_id, list)) = hard_forks.get(&(hash, number)) {
|
||||
current_set_id = *set_id;
|
||||
current_authorities = list.clone();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user