diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-07-10 17:43:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-10 17:43:23 +0800 |
commit | 4f7a38001f7137972303421a11d49b0745450a3a (patch) | |
tree | 0a486e90fd8cf7d2ab161610b79a2251483895c0 /core/tx_list.go | |
parent | 65f0e905ddda9be97368839b67be5754b33a0eea (diff) | |
parent | 34ec9913f628180d0ace740abfe1362995879c93 (diff) | |
download | go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.gz go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.bz2 go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.lz go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.xz go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.zst go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.zip |
Merge pull request #14737 from holiman/txpool_localaccounts
Txpool localaccounts
Diffstat (limited to 'core/tx_list.go')
-rw-r--r-- | core/tx_list.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/core/tx_list.go b/core/tx_list.go index 626d3a3b7..0d87c20bc 100644 --- a/core/tx_list.go +++ b/core/tx_list.go @@ -420,18 +420,16 @@ func (l *txPricedList) Removed() { heap.Init(l.items) } -// Discard finds all the transactions below the given price threshold, drops them +// Cap finds all the transactions below the given price threshold, drops them // from the priced list and returs them for further removal from the entire pool. -func (l *txPricedList) Cap(threshold *big.Int, local *txSet) types.Transactions { +func (l *txPricedList) Cap(threshold *big.Int, local *accountSet) types.Transactions { drop := make(types.Transactions, 0, 128) // Remote underpriced transactions to drop save := make(types.Transactions, 0, 64) // Local underpriced transactions to keep for len(*l.items) > 0 { // Discard stale transactions if found during cleanup tx := heap.Pop(l.items).(*types.Transaction) - - hash := tx.Hash() - if _, ok := (*l.all)[hash]; !ok { + if _, ok := (*l.all)[tx.Hash()]; !ok { l.stales-- continue } @@ -440,7 +438,7 @@ func (l *txPricedList) Cap(threshold *big.Int, local *txSet) types.Transactions break } // Non stale transaction found, discard unless local - if local.contains(hash) { + if local.containsTx(tx) { save = append(save, tx) } else { drop = append(drop, tx) @@ -454,9 +452,9 @@ func (l *txPricedList) Cap(threshold *big.Int, local *txSet) types.Transactions // Underpriced checks whether a transaction is cheaper than (or as cheap as) the // lowest priced transaction currently being tracked. -func (l *txPricedList) Underpriced(tx *types.Transaction, local *txSet) bool { +func (l *txPricedList) Underpriced(tx *types.Transaction, local *accountSet) bool { // Local transactions cannot be underpriced - if local.contains(tx.Hash()) { + if local.containsTx(tx) { return false } // Discard stale price points if found at the heap start @@ -479,22 +477,20 @@ func (l *txPricedList) Underpriced(tx *types.Transaction, local *txSet) bool { } // Discard finds a number of most underpriced transactions, removes them from the -// priced list and returs them for further removal from the entire pool. -func (l *txPricedList) Discard(count int, local *txSet) types.Transactions { +// priced list and returns them for further removal from the entire pool. +func (l *txPricedList) Discard(count int, local *accountSet) types.Transactions { drop := make(types.Transactions, 0, count) // Remote underpriced transactions to drop save := make(types.Transactions, 0, 64) // Local underpriced transactions to keep for len(*l.items) > 0 && count > 0 { // Discard stale transactions if found during cleanup tx := heap.Pop(l.items).(*types.Transaction) - - hash := tx.Hash() - if _, ok := (*l.all)[hash]; !ok { + if _, ok := (*l.all)[tx.Hash()]; !ok { l.stales-- continue } // Non stale transaction found, discard unless local - if local.contains(hash) { + if local.containsTx(tx) { save = append(save, tx) } else { drop = append(drop, tx) |