mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +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
@@ -268,7 +268,7 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf> StateDbSync<Block
|
||||
let db_mode = db.get_meta(&to_meta_key(PRUNING_MODE, &())).map_err(Error::Db)?;
|
||||
trace!(target: "state-db",
|
||||
"DB pruning mode: {:?}",
|
||||
db_mode.as_ref().map(|v| std::str::from_utf8(&v))
|
||||
db_mode.as_ref().map(|v| std::str::from_utf8(v))
|
||||
);
|
||||
match &db_mode {
|
||||
Some(v) if v.as_slice() == mode.id() => Ok(()),
|
||||
@@ -314,7 +314,7 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf> StateDbSync<Block
|
||||
if self.mode == PruningMode::ArchiveAll {
|
||||
return Ok(commit)
|
||||
}
|
||||
match self.non_canonical.canonicalize(&hash, &mut commit) {
|
||||
match self.non_canonical.canonicalize(hash, &mut commit) {
|
||||
Ok(()) =>
|
||||
if self.mode == PruningMode::ArchiveCanonical {
|
||||
commit.data.deleted.clear();
|
||||
@@ -322,14 +322,14 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf> StateDbSync<Block
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
if let Some(ref mut pruning) = self.pruning {
|
||||
pruning.note_canonical(&hash, &mut commit);
|
||||
pruning.note_canonical(hash, &mut commit);
|
||||
}
|
||||
self.prune(&mut commit);
|
||||
Ok(commit)
|
||||
}
|
||||
|
||||
fn best_canonical(&self) -> Option<u64> {
|
||||
return self.non_canonical.last_canonicalized_block_number()
|
||||
self.non_canonical.last_canonicalized_block_number()
|
||||
}
|
||||
|
||||
fn is_pruned(&self, hash: &BlockHash, number: u64) -> bool {
|
||||
@@ -438,7 +438,7 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf> StateDbSync<Block
|
||||
if let Some(value) = self.non_canonical.get(key) {
|
||||
return Ok(Some(value))
|
||||
}
|
||||
db.get(key.as_ref()).map_err(|e| Error::Db(e))
|
||||
db.get(key.as_ref()).map_err(Error::Db)
|
||||
}
|
||||
|
||||
fn apply_pending(&mut self) {
|
||||
|
||||
@@ -127,7 +127,7 @@ fn discard_values<Key: Hash>(values: &mut HashMap<Key, (u32, DBValue)>, inserted
|
||||
|
||||
fn discard_descendants<BlockHash: Hash, Key: Hash>(
|
||||
levels: &mut (&mut [OverlayLevel<BlockHash, Key>], &mut [OverlayLevel<BlockHash, Key>]),
|
||||
mut values: &mut HashMap<Key, (u32, DBValue)>,
|
||||
values: &mut HashMap<Key, (u32, DBValue)>,
|
||||
parents: &mut HashMap<BlockHash, BlockHash>,
|
||||
pinned: &HashMap<BlockHash, u32>,
|
||||
pinned_insertions: &mut HashMap<BlockHash, (Vec<Key>, u32)>,
|
||||
@@ -135,12 +135,10 @@ fn discard_descendants<BlockHash: Hash, Key: Hash>(
|
||||
) -> u32 {
|
||||
let (first, mut remainder) = if let Some((first, rest)) = levels.0.split_first_mut() {
|
||||
(Some(first), (rest, &mut *levels.1))
|
||||
} else if let Some((first, rest)) = levels.1.split_first_mut() {
|
||||
(Some(first), (&mut *levels.0, rest))
|
||||
} else {
|
||||
if let Some((first, rest)) = levels.1.split_first_mut() {
|
||||
(Some(first), (&mut *levels.0, rest))
|
||||
} else {
|
||||
(None, (&mut *levels.0, &mut *levels.1))
|
||||
}
|
||||
(None, (&mut *levels.0, &mut *levels.1))
|
||||
};
|
||||
let mut pinned_children = 0;
|
||||
if let Some(level) = first {
|
||||
@@ -169,7 +167,7 @@ fn discard_descendants<BlockHash: Hash, Key: Hash>(
|
||||
} else {
|
||||
// discard immediately.
|
||||
parents.remove(&overlay.hash);
|
||||
discard_values(&mut values, overlay.inserted);
|
||||
discard_values(values, overlay.inserted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +178,7 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
/// Creates a new instance. Does not expect any metadata to be present in the DB.
|
||||
pub fn new<D: MetaDb>(db: &D) -> Result<NonCanonicalOverlay<BlockHash, Key>, Error<D::Error>> {
|
||||
let last_canonicalized =
|
||||
db.get_meta(&to_meta_key(LAST_CANONICAL, &())).map_err(|e| Error::Db(e))?;
|
||||
db.get_meta(&to_meta_key(LAST_CANONICAL, &())).map_err(Error::Db)?;
|
||||
let last_canonicalized = last_canonicalized
|
||||
.map(|buffer| <(BlockHash, u64)>::decode(&mut buffer.as_slice()))
|
||||
.transpose()?;
|
||||
@@ -196,7 +194,7 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
let mut level = OverlayLevel::new();
|
||||
for index in 0..MAX_BLOCKS_PER_LEVEL {
|
||||
let journal_key = to_journal_key(block, index);
|
||||
if let Some(record) = db.get_meta(&journal_key).map_err(|e| Error::Db(e))? {
|
||||
if let Some(record) = db.get_meta(&journal_key).map_err(Error::Db)? {
|
||||
let record: JournalRecord<BlockHash, Key> =
|
||||
Decode::decode(&mut record.as_slice())?;
|
||||
let inserted = record.inserted.iter().map(|(k, _)| k.clone()).collect();
|
||||
@@ -280,7 +278,7 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
{
|
||||
return Err(Error::InvalidParent)
|
||||
}
|
||||
} else if !self.parents.contains_key(&parent_hash) {
|
||||
} else if !self.parents.contains_key(parent_hash) {
|
||||
return Err(Error::InvalidParent)
|
||||
}
|
||||
}
|
||||
@@ -391,12 +389,12 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
let level = self
|
||||
.levels
|
||||
.get(self.pending_canonicalizations.len())
|
||||
.ok_or_else(|| Error::InvalidBlock)?;
|
||||
.ok_or(Error::InvalidBlock)?;
|
||||
let index = level
|
||||
.blocks
|
||||
.iter()
|
||||
.position(|overlay| overlay.hash == *hash)
|
||||
.ok_or_else(|| Error::InvalidBlock)?;
|
||||
.ok_or(Error::InvalidBlock)?;
|
||||
|
||||
let mut discarded_journals = Vec::new();
|
||||
let mut discarded_blocks = Vec::new();
|
||||
@@ -493,10 +491,7 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
Key: std::borrow::Borrow<Q>,
|
||||
Q: std::hash::Hash + Eq,
|
||||
{
|
||||
if let Some((_, value)) = self.values.get(&key) {
|
||||
return Some(value.clone())
|
||||
}
|
||||
None
|
||||
self.values.get(key).map(|v| v.1.clone())
|
||||
}
|
||||
|
||||
/// Check if the block is in the canonicalization queue.
|
||||
|
||||
@@ -76,7 +76,7 @@ impl<BlockHash: Hash, Key: Hash> RefWindow<BlockHash, Key> {
|
||||
db: &D,
|
||||
count_insertions: bool,
|
||||
) -> Result<RefWindow<BlockHash, Key>, Error<D::Error>> {
|
||||
let last_pruned = db.get_meta(&to_meta_key(LAST_PRUNED, &())).map_err(|e| Error::Db(e))?;
|
||||
let last_pruned = db.get_meta(&to_meta_key(LAST_PRUNED, &())).map_err(Error::Db)?;
|
||||
let pending_number: u64 = match last_pruned {
|
||||
Some(buffer) => u64::decode(&mut buffer.as_slice())? + 1,
|
||||
None => 0,
|
||||
@@ -94,7 +94,7 @@ impl<BlockHash: Hash, Key: Hash> RefWindow<BlockHash, Key> {
|
||||
trace!(target: "state-db", "Reading pruning journal. Pending #{}", pending_number);
|
||||
loop {
|
||||
let journal_key = to_journal_key(block);
|
||||
match db.get_meta(&journal_key).map_err(|e| Error::Db(e))? {
|
||||
match db.get_meta(&journal_key).map_err(Error::Db)? {
|
||||
Some(record) => {
|
||||
let record: JournalRecord<BlockHash, Key> =
|
||||
Decode::decode(&mut record.as_slice())?;
|
||||
@@ -208,7 +208,7 @@ impl<BlockHash: Hash, Key: Hash> RefWindow<BlockHash, Key> {
|
||||
trace!(target: "state-db", "Applying pruning {:?} ({} deleted)", pruned.hash, pruned.deleted.len());
|
||||
if self.count_insertions {
|
||||
for k in pruned.deleted.iter() {
|
||||
self.death_index.remove(&k);
|
||||
self.death_index.remove(k);
|
||||
}
|
||||
}
|
||||
self.pending_number += 1;
|
||||
|
||||
Reference in New Issue
Block a user