Fix panic on importing own invalid transaction (#3550)

This commit is contained in:
Arkadiy Paronyan 2016-11-23 08:46:55 +01:00 committed by Tomasz Drwięga
parent cbeb2dc3f9
commit a969c008d1

View File

@ -580,29 +580,29 @@ impl Miner {
let gas_required = |tx: &SignedTransaction| tx.gas_required(&schedule).into(); let gas_required = |tx: &SignedTransaction| tx.gas_required(&schedule).into();
let best_block_header: Header = ::rlp::decode(&chain.best_block_header()); let best_block_header: Header = ::rlp::decode(&chain.best_block_header());
transactions.into_iter() transactions.into_iter()
.filter(|tx| match self.engine.verify_transaction_basic(tx, &best_block_header) { .map(|tx| {
Ok(()) => true, match self.engine.verify_transaction_basic(&tx, &best_block_header) {
Err(e) => { Err(e) => {
debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e); debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e);
false Err(e)
} },
} Ok(()) => {
) let origin = accounts.as_ref().and_then(|accounts| {
.map(|tx| { tx.sender().ok().and_then(|sender| match accounts.contains(&sender) {
let origin = accounts.as_ref().and_then(|accounts| { true => Some(TransactionOrigin::Local),
tx.sender().ok().and_then(|sender| match accounts.contains(&sender) { false => None,
true => Some(TransactionOrigin::Local), })
false => None, }).unwrap_or(default_origin);
})
}).unwrap_or(default_origin); match origin {
TransactionOrigin::Local | TransactionOrigin::RetractedBlock => {
match origin { transaction_queue.add(tx, origin, &fetch_account, &gas_required)
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() .collect()