Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: fine grained lock for TxPool.all #197

Merged
merged 2 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/tx_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,18 @@ func (l *txList) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Tran
}
}
// Otherwise overwrite the old transaction with the current one
l.add(tx)
return true, old
}

func (l *txList) add(tx *types.Transaction) {
Copy link
Contributor Author

@jmank88 jmank88 May 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enqueueTx() and Add() handle queueing a tx which might replace an existing transaction. Most callers were cases where the tx was being moved from pending, so we know it's not a replacement, and we can just call this simplified add() method directly instead.

l.txs.Put(tx)
if cost := tx.Cost(); l.costcap.Cmp(cost) < 0 {
l.costcap = cost
}
if gas := tx.Gas(); l.gascap < gas {
l.gascap = gas
}
return true, old
}

// Forward removes all transactions from the list with a nonce lower than the
Expand Down
Loading