From fece330ca4e2cc31a9a22ea7705033b9e967fb4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 17 Mar 2016 15:30:03 +0100 Subject: [PATCH] Refactoring removing invalid transactions from queue --- miner/src/miner.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/miner/src/miner.rs b/miner/src/miner.rs index 776cf7c83..6be2da512 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -133,19 +133,14 @@ impl MinerService for Miner { transactions, ); - match b { - None => { - *self.sealing_block.lock().unwrap() = None - }, - Some((block, invalid_transactions)) => { - let mut queue = self.transaction_queue.lock().unwrap(); - queue.remove_all( - &invalid_transactions.into_iter().collect::>(), - |a: &Address| chain.nonce(a) - ); - *self.sealing_block.lock().unwrap() = Some(block) - } - } + *self.sealing_block.lock().unwrap() = b.map(|(block, invalid_transactions)| { + let mut queue = self.transaction_queue.lock().unwrap(); + queue.remove_all( + &invalid_transactions.into_iter().collect::>(), + |a: &Address| chain.nonce(a) + ); + block + }); } fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex> {