Removes redundant `mut` in sync

This commit is contained in:
Dmitry Kashitsyn 2017-10-15 20:11:20 +07:00
parent dab40e832c
commit 74876fd410
2 changed files with 7 additions and 7 deletions

View File

@ -459,7 +459,7 @@ impl ChainSync {
/// Updates transactions were received by a peer
pub fn transactions_received(&mut self, hashes: Vec<H256>, peer_id: PeerId) {
if let Some(mut peer_info) = self.peers.get_mut(&peer_id) {
if let Some(peer_info) = self.peers.get_mut(&peer_id) {
peer_info.last_sent_transactions.extend(&hashes);
}
}
@ -730,7 +730,7 @@ impl ChainSync {
}
let result = {
let mut downloader = match block_set {
let downloader = match block_set {
BlockSet::NewBlocks => &mut self.new_blocks,
BlockSet::OldBlocks => {
match self.old_blocks {
@ -795,7 +795,7 @@ impl ChainSync {
else
{
let result = {
let mut downloader = match block_set {
let downloader = match block_set {
BlockSet::NewBlocks => &mut self.new_blocks,
BlockSet::OldBlocks => match self.old_blocks {
None => {
@ -849,7 +849,7 @@ impl ChainSync {
else
{
let result = {
let mut downloader = match block_set {
let downloader = match block_set {
BlockSet::NewBlocks => &mut self.new_blocks,
BlockSet::OldBlocks => match self.old_blocks {
None => {
@ -2186,7 +2186,7 @@ impl ChainSync {
// Select random peer to re-broadcast transactions to.
let peer = random::new().gen_range(0, self.peers.len());
trace!(target: "sync", "Re-broadcasting transactions to a random peer.");
self.peers.values_mut().nth(peer).map(|mut peer_info|
self.peers.values_mut().nth(peer).map(|peer_info|
peer_info.last_sent_transactions.clear()
);
}

View File

@ -57,8 +57,8 @@ impl TransactionsStats {
/// Increases number of propagations to given `enodeid`.
pub fn propagated(&mut self, hash: &H256, enode_id: Option<NodeId>, current_block_num: BlockNumber) {
let enode_id = enode_id.unwrap_or_default();
let mut stats = self.pending_transactions.entry(*hash).or_insert_with(|| Stats::new(current_block_num));
let mut count = stats.propagated_to.entry(enode_id).or_insert(0);
let stats = self.pending_transactions.entry(*hash).or_insert_with(|| Stats::new(current_block_num));
let count = stats.propagated_to.entry(enode_id).or_insert(0);
*count = count.saturating_add(1);
}