Skip to content

Commit

Permalink
Split into elif in order to deal with pending or queue
Browse files Browse the repository at this point in the history
  • Loading branch information
villanuevawill committed Jul 2, 2020
1 parent 176e6e5 commit 6321014
Showing 1 changed file with 10 additions and 40 deletions.
50 changes: 10 additions & 40 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,32 +1231,6 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
}
}

// for AA we need to re-validate accounts that were included
// split into separate function
// This introduces some basic race conditions, so this needs to be refactored
for _, tx := range included {
var account = tx.To()
if account != nil && tx.IsAA() {
if pool.Has(tx.Hash()) {
pool.removeTx(tx.Hash(), true)
} else {
if pending := pool.pending[*account]; pending != nil {
pending_tx := pending.txs.Flatten()[0]
pool.removeTx(pending_tx.Hash(), true)
// ignore locals for now
pool.add(pending_tx, false)
}

if queued := pool.queue[*account]; queued != nil {
queued_tx := queued.txs.Flatten()[0]
pool.removeTx(queued_tx.Hash(), true)
// ignore locals for now
pool.add(queued_tx, false)
}
}
}
}

// Initialize the internal state to the current head
if newHead == nil {
newHead = pool.chain.CurrentBlock().Header() // Special case during testing
Expand Down Expand Up @@ -1296,20 +1270,16 @@ func (pool *TxPool) validateAAExecutables(txs []*types.Transaction) {
if account != nil && tx.IsAA() {
if pool.Has(tx.Hash()) {
pool.removeTx(tx.Hash(), true)
} else {
if pending := pool.pending[*account]; pending != nil {
pending_tx := pending.txs.Flatten()[0]
pool.removeTx(pending_tx.Hash(), true)
// ignore locals for now
pool.add(pending_tx, false)
}

if queued := pool.queue[*account]; queued != nil {
queued_tx := queued.txs.Flatten()[0]
pool.removeTx(queued_tx.Hash(), true)
// ignore locals for now
pool.add(queued_tx, false)
}
} else if pending := pool.pending[*account]; pending != nil {
pending_tx := pending.txs.Flatten()[0]
pool.removeTx(pending_tx.Hash(), true)
// ignore locals for now
pool.add(pending_tx, false)
} else if queued := pool.queue[*account]; queued != nil {
queued_tx := queued.txs.Flatten()[0]
pool.removeTx(queued_tx.Hash(), true)
// ignore locals for now
pool.add(queued_tx, false)
}
}
}
Expand Down

0 comments on commit 6321014

Please sign in to comment.