Fixing inconsistency when replacing transactions in queue

This commit is contained in:
Tomasz Drwięga 2016-03-05 17:41:35 +01:00
parent 18cbea394d
commit 4a53d62be4

View File

@ -348,8 +348,8 @@ impl TransactionQueue {
return; return;
} }
let nonce = tx.nonce();
let address = tx.sender(); let address = tx.sender();
let nonce = tx.nonce();
let state_nonce = fetch_nonce(&address); let state_nonce = fetch_nonce(&address);
let next_nonce = self.last_nonces let next_nonce = self.last_nonces
@ -370,7 +370,6 @@ impl TransactionQueue {
} }
let base_nonce = fetch_nonce(&address); let base_nonce = fetch_nonce(&address);
Self::replace_transaction(tx, base_nonce.clone(), &mut self.current, &mut self.by_hash); Self::replace_transaction(tx, base_nonce.clone(), &mut self.current, &mut self.by_hash);
self.last_nonces.insert(address.clone(), nonce); self.last_nonces.insert(address.clone(), nonce);
// But maybe there are some more items waiting in future? // But maybe there are some more items waiting in future?
@ -391,7 +390,9 @@ impl TransactionQueue {
let new_fee = order.gas_price; let new_fee = order.gas_price;
if old_fee.cmp(&new_fee) == Ordering::Greater { if old_fee.cmp(&new_fee) == Ordering::Greater {
// Put back old transaction since it has greater priority (higher gas_price) // Put back old transaction since it has greater priority (higher gas_price)
set.insert(address, nonce, old); set.by_address.insert(address, nonce, old);
// and remove new one
set.by_priority.remove(&order);
by_hash.remove(&hash); by_hash.remove(&hash);
} else { } else {
// Make sure we remove old transaction entirely // Make sure we remove old transaction entirely