From a969c008d172697b786b2e545930a88b0df42d60 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Wed, 23 Nov 2016 08:46:55 +0100 Subject: [PATCH] Fix panic on importing own invalid transaction (#3550) --- ethcore/src/miner/miner.rs | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 7ad18ebfc..9d4e66918 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -580,29 +580,29 @@ impl Miner { let gas_required = |tx: &SignedTransaction| tx.gas_required(&schedule).into(); let best_block_header: Header = ::rlp::decode(&chain.best_block_header()); transactions.into_iter() - .filter(|tx| match self.engine.verify_transaction_basic(tx, &best_block_header) { - Ok(()) => true, + .map(|tx| { + match self.engine.verify_transaction_basic(&tx, &best_block_header) { Err(e) => { debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e); - false - } - } - ) - .map(|tx| { - let origin = accounts.as_ref().and_then(|accounts| { - tx.sender().ok().and_then(|sender| match accounts.contains(&sender) { - true => Some(TransactionOrigin::Local), - false => None, - }) - }).unwrap_or(default_origin); - - match origin { - TransactionOrigin::Local | TransactionOrigin::RetractedBlock => { - transaction_queue.add(tx, origin, &fetch_account, &gas_required) + Err(e) + }, + Ok(()) => { + let origin = accounts.as_ref().and_then(|accounts| { + tx.sender().ok().and_then(|sender| match accounts.contains(&sender) { + true => Some(TransactionOrigin::Local), + false => None, + }) + }).unwrap_or(default_origin); + + match origin { + TransactionOrigin::Local | TransactionOrigin::RetractedBlock => { + transaction_queue.add(tx, origin, &fetch_account, &gas_required) + }, + TransactionOrigin::External => { + transaction_queue.add_with_banlist(tx, &fetch_account, &gas_required) + } + } }, - TransactionOrigin::External => { - transaction_queue.add_with_banlist(tx, &fetch_account, &gas_required) - } } }) .collect()