diff --git a/ethcore/src/account_provider/stores.rs b/ethcore/src/account_provider/stores.rs index 72bc04da6..45652a8a6 100644 --- a/ethcore/src/account_provider/stores.rs +++ b/ethcore/src/account_provider/stores.rs @@ -64,7 +64,7 @@ impl AddressBook { /// Sets new name for given address. pub fn set_name(&mut self, a: Address, name: String) { { - let mut x = self.cache.entry(a) + let x = self.cache.entry(a) .or_insert_with(|| AccountMeta {name: Default::default(), meta: "{}".to_owned(), uuid: None}); x.name = name; } @@ -74,7 +74,7 @@ impl AddressBook { /// Sets new meta for given address. pub fn set_meta(&mut self, a: Address, meta: String) { { - let mut x = self.cache.entry(a) + let x = self.cache.entry(a) .or_insert_with(|| AccountMeta {name: "Anonymous".to_owned(), meta: Default::default(), uuid: None}); x.meta = meta; } @@ -253,7 +253,7 @@ impl DappsSettingsStore { /// Marks recent dapp as used pub fn mark_dapp_used(&mut self, dapp: DappId) { { - let mut entry = self.history.entry(dapp).or_insert_with(|| Default::default()); + let entry = self.history.entry(dapp).or_insert_with(|| Default::default()); entry.last_accessed = self.time.get(); } // Clear extraneous entries @@ -280,7 +280,7 @@ impl DappsSettingsStore { /// Sets accounts for specific dapp. pub fn set_accounts(&mut self, id: DappId, accounts: Option>) { { - let mut settings = self.settings.entry(id).or_insert_with(DappsSettings::default); + let settings = self.settings.entry(id).or_insert_with(DappsSettings::default); settings.accounts = accounts; } self.settings.save(JsonSettings::write); @@ -289,7 +289,7 @@ impl DappsSettingsStore { /// Sets a default account for specific dapp. pub fn set_default(&mut self, id: DappId, default: Address) { { - let mut settings = self.settings.entry(id).or_insert_with(DappsSettings::default); + let settings = self.settings.entry(id).or_insert_with(DappsSettings::default); settings.default = Some(default); } self.settings.save(JsonSettings::write); diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 2e583b179..802b4ab88 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -421,7 +421,7 @@ pub mod common { .and_then(|_| fields.state.commit()); let block_author = fields.header.author().clone(); - fields.traces.as_mut().map(move |mut traces| { + fields.traces.as_mut().map(move |traces| { let mut tracer = ExecutiveTracer::default(); tracer.trace_reward(block_author, reward, RewardType::Block); traces.push(tracer.drain()) diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 2a70689db..3709ea449 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -433,7 +433,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> { // trace only top level calls to builtins to avoid DDoS attacks if self.depth == 0 { let mut trace_output = tracer.prepare_trace_output(); - if let Some(mut out) = trace_output.as_mut() { + if let Some(out) = trace_output.as_mut() { *out = output.to_owned(); } diff --git a/ethcore/src/miner/banning_queue.rs b/ethcore/src/miner/banning_queue.rs index a446da29e..d89c30b86 100644 --- a/ethcore/src/miner/banning_queue.rs +++ b/ethcore/src/miner/banning_queue.rs @@ -149,7 +149,7 @@ impl BanningTransactionQueue { /// queue. fn ban_sender(&mut self, address: Address) -> bool { let count = { - let mut count = self.senders_bans.entry(address).or_insert_with(|| 0); + let count = self.senders_bans.entry(address).or_insert_with(|| 0); *count = count.saturating_add(1); *count }; @@ -169,7 +169,7 @@ impl BanningTransactionQueue { /// Returns true if bans threshold has been reached. fn ban_recipient(&mut self, address: Address) -> bool { let count = { - let mut count = self.recipients_bans.entry(address).or_insert_with(|| 0); + let count = self.recipients_bans.entry(address).or_insert_with(|| 0); *count = count.saturating_add(1); *count }; @@ -185,7 +185,7 @@ impl BanningTransactionQueue { /// If bans threshold is reached all subsequent transactions to contracts with this codehash will be rejected. /// Returns true if bans threshold has been reached. fn ban_codehash(&mut self, code_hash: H256) -> bool { - let mut count = self.codes_bans.entry(code_hash).or_insert_with(|| 0); + let count = self.codes_bans.entry(code_hash).or_insert_with(|| 0); *count = count.saturating_add(1); match self.ban_threshold { diff --git a/ethcore/src/miner/transaction_queue.rs b/ethcore/src/miner/transaction_queue.rs index 0234af068..2accbecc0 100644 --- a/ethcore/src/miner/transaction_queue.rs +++ b/ethcore/src/miner/transaction_queue.rs @@ -341,7 +341,7 @@ impl GasPriceQueue { /// Remove an item from a BTreeMap/HashSet "multimap". /// Returns true if the item was removed successfully. pub fn remove(&mut self, gas_price: &U256, hash: &H256) -> bool { - if let Some(mut hashes) = self.backing.get_mut(gas_price) { + if let Some(hashes) = self.backing.get_mut(gas_price) { let only_one_left = hashes.len() == 1; if !only_one_left { // Operation may be ok: only if hash is in gas-price's Set. @@ -1225,7 +1225,7 @@ impl TransactionQueue { if by_nonce.is_none() { return; } - let mut by_nonce = by_nonce.expect("None is tested in early-exit condition above; qed"); + let by_nonce = by_nonce.expect("None is tested in early-exit condition above; qed"); while let Some(order) = by_nonce.remove(¤t_nonce) { // remove also from priority and gas_price self.future.by_priority.remove(&order); diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 96fd46ec5..dfde05921 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -962,7 +962,7 @@ impl State { // at this point the entry is guaranteed to be in the cache. Ok(RefMut::map(self.cache.borrow_mut(), |c| { - let mut entry = c.get_mut(a).expect("entry known to exist in the cache; qed"); + let entry = c.get_mut(a).expect("entry known to exist in the cache; qed"); match &mut entry.account { &mut Some(ref mut acc) => not_default(acc), diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index 6d2885a5a..a2e4dcac4 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -211,7 +211,7 @@ impl StateDB { pub fn sync_cache(&mut self, enacted: &[H256], retracted: &[H256], is_best: bool) { trace!("sync_cache id = (#{:?}, {:?}), parent={:?}, best={}", self.commit_number, self.commit_hash, self.parent_hash, is_best); let mut cache = self.account_cache.lock(); - let mut cache = &mut *cache; + let cache = &mut *cache; // Purge changes from re-enacted and retracted blocks. // Filter out commiting block if any. diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 198c63287..bf7c9ef5c 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -522,7 +522,7 @@ impl VerificationQueue { return; } let mut verified_lock = self.verification.verified.lock(); - let mut verified = &mut *verified_lock; + let verified = &mut *verified_lock; let mut bad = self.verification.bad.lock(); let mut processing = self.processing.write(); bad.reserve(hashes.len()); diff --git a/ethstore/src/dir/memory.rs b/ethstore/src/dir/memory.rs index b8c2ad9ff..bd162b5ef 100644 --- a/ethstore/src/dir/memory.rs +++ b/ethstore/src/dir/memory.rs @@ -35,7 +35,7 @@ impl KeyDirectory for MemoryDirectory { fn update(&self, account: SafeAccount) -> Result { let mut lock = self.accounts.write(); - let mut accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new); + let accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new); // If the filename is the same we just need to replace the entry accounts.retain(|acc| acc.filename != account.filename); accounts.push(account.clone()); @@ -44,14 +44,14 @@ impl KeyDirectory for MemoryDirectory { fn insert(&self, account: SafeAccount) -> Result { let mut lock = self.accounts.write(); - let mut accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new); + let accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new); accounts.push(account.clone()); Ok(account) } fn remove(&self, account: &SafeAccount) -> Result<(), Error> { let mut accounts = self.accounts.write(); - let is_empty = if let Some(mut accounts) = accounts.get_mut(&account.address) { + let is_empty = if let Some(accounts) = accounts.get_mut(&account.address) { if let Some(position) = accounts.iter().position(|acc| acc == account) { accounts.remove(position); } diff --git a/ethstore/src/ethstore.rs b/ethstore/src/ethstore.rs index f3bb24071..7588cc9fb 100755 --- a/ethstore/src/ethstore.rs +++ b/ethstore/src/ethstore.rs @@ -358,7 +358,7 @@ impl EthMultiStore { // update cache let mut cache = self.cache.write(); - let mut accounts = cache.entry(account_ref.clone()).or_insert_with(Vec::new); + let accounts = cache.entry(account_ref.clone()).or_insert_with(Vec::new); // Remove old account accounts.retain(|acc| acc != &old); // And push updated to the end