fixed clippy warnings

This commit is contained in:
Svyatoslav Nikolsky 2016-11-17 14:20:37 +03:00
parent 26ab437024
commit 5d18a770d4
3 changed files with 15 additions and 9 deletions

View File

@ -92,17 +92,19 @@ impl OrphanBlocksPool {
let parent_orphan_keys: Vec<_> = self.orphaned_blocks.keys().cloned().collect(); let parent_orphan_keys: Vec<_> = self.orphaned_blocks.keys().cloned().collect();
for parent_orphan_key in parent_orphan_keys { for parent_orphan_key in parent_orphan_keys {
if let Entry::Occupied(mut orphan_entry) = self.orphaned_blocks.entry(parent_orphan_key) { if let Entry::Occupied(mut orphan_entry) = self.orphaned_blocks.entry(parent_orphan_key) {
if { let remove_entry = {
let mut orphans = orphan_entry.get_mut(); let mut orphans = orphan_entry.get_mut();
let orphans_keys: HashSet<H256> = orphans.keys().cloned().collect(); let orphans_keys: HashSet<H256> = orphans.keys().cloned().collect();
for orphan_to_remove in orphans_keys.intersection(&hashes) { for orphan_to_remove in orphans_keys.intersection(hashes) {
self.unknown_blocks.remove(orphan_to_remove); self.unknown_blocks.remove(orphan_to_remove);
removed.push((orphan_to_remove.clone(), removed.push((orphan_to_remove.clone(),
orphans.remove(orphan_to_remove).expect("iterating by intersection of orphans keys with hashes; removing from orphans; qed") orphans.remove(orphan_to_remove).expect("iterating by intersection of orphans keys with hashes; removing from orphans; qed")
)); ));
} }
orphans.is_empty() orphans.is_empty()
} { };
if remove_entry {
orphan_entry.remove_entry(); orphan_entry.remove_entry();
} }
} }

View File

@ -549,7 +549,7 @@ impl Chain {
while let Some(hash) = queue.pop_front() { while let Some(hash) = queue.pop_front() {
let all_keys: Vec<_> = self.verifying_transactions.keys().cloned().collect(); let all_keys: Vec<_> = self.verifying_transactions.keys().cloned().collect();
for h in all_keys { for h in all_keys {
if { let remove_verifying_transaction = {
if let Some(entry) = self.verifying_transactions.get(&h) { if let Some(entry) = self.verifying_transactions.get(&h) {
if entry.inputs.iter().any(|i| i.previous_output.hash == hash) { if entry.inputs.iter().any(|i| i.previous_output.hash == hash) {
queue.push_back(h.clone()); queue.push_back(h.clone());
@ -561,7 +561,9 @@ impl Chain {
// iterating by previously read keys // iterating by previously read keys
unreachable!() unreachable!()
} }
} { };
if remove_verifying_transaction {
self.verifying_transactions.remove(&h); self.verifying_transactions.remove(&h);
} }
} }

View File

@ -350,7 +350,7 @@ impl<T> Client for SynchronizationClient<T> where T: TaskExecutor {
let unknown_transactions_hashes: Vec<_> = { let unknown_transactions_hashes: Vec<_> = {
let chain = self.chain.read(); let chain = self.chain.read();
transactions_hashes.into_iter() transactions_hashes.into_iter()
.filter(|h| chain.transaction_state(&h) == TransactionState::Unknown) .filter(|h| chain.transaction_state(h) == TransactionState::Unknown)
.collect() .collect()
}; };
@ -557,7 +557,7 @@ impl<T> Client for SynchronizationClient<T> where T: TaskExecutor {
let mut chain = self.chain.write(); let mut chain = self.chain.write();
// forget for this transaction and all its children // forget for this transaction and all its children
chain.forget_verifying_transaction_with_children(&hash); chain.forget_verifying_transaction_with_children(hash);
} }
} }
} }
@ -979,7 +979,7 @@ impl<T> SynchronizationClient<T> where T: TaskExecutor {
let peer_index = *block_entry.get(); let peer_index = *block_entry.get();
// find a # of blocks, which this thread has supplied // find a # of blocks, which this thread has supplied
if let Entry::Occupied(mut entry) = self.verifying_blocks_waiters.entry(peer_index) { if let Entry::Occupied(mut entry) = self.verifying_blocks_waiters.entry(peer_index) {
if { let is_last_block = {
let &mut (ref mut waiting, ref waiter) = entry.get_mut(); let &mut (ref mut waiting, ref waiter) = entry.get_mut();
waiting.remove(hash); waiting.remove(hash);
// if this is the last block => awake waiting threads // if this is the last block => awake waiting threads
@ -990,7 +990,9 @@ impl<T> SynchronizationClient<T> where T: TaskExecutor {
} }
} }
is_last_block is_last_block
} { };
if is_last_block {
entry.remove_entry(); entry.remove_entry();
} }
} }