aboutsummaryrefslogtreecommitdiffstats
path: root/core/tx_list.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/tx_list.go')
-rw-r--r--core/tx_list.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/core/tx_list.go b/core/tx_list.go
index ea6ee7019..287dda4c3 100644
--- a/core/tx_list.go
+++ b/core/tx_list.go
@@ -397,13 +397,13 @@ func (h *priceHeap) Pop() interface{} {
// txPricedList is a price-sorted heap to allow operating on transactions pool
// contents in a price-incrementing way.
type txPricedList struct {
- all *map[common.Hash]*types.Transaction // Pointer to the map of all transactions
- items *priceHeap // Heap of prices of all the stored transactions
- stales int // Number of stale price points to (re-heap trigger)
+ all *txLookup // Pointer to the map of all transactions
+ items *priceHeap // Heap of prices of all the stored transactions
+ stales int // Number of stale price points to (re-heap trigger)
}
// newTxPricedList creates a new price-sorted transaction heap.
-func newTxPricedList(all *map[common.Hash]*types.Transaction) *txPricedList {
+func newTxPricedList(all *txLookup) *txPricedList {
return &txPricedList{
all: all,
items: new(priceHeap),
@@ -425,12 +425,13 @@ func (l *txPricedList) Removed() {
return
}
// Seems we've reached a critical number of stale transactions, reheap
- reheap := make(priceHeap, 0, len(*l.all))
+ reheap := make(priceHeap, 0, l.all.Count())
l.stales, l.items = 0, &reheap
- for _, tx := range *l.all {
+ l.all.Range(func(hash common.Hash, tx *types.Transaction) bool {
*l.items = append(*l.items, tx)
- }
+ return true
+ })
heap.Init(l.items)
}
@@ -443,7 +444,7 @@ func (l *txPricedList) Cap(threshold *big.Int, local *accountSet) types.Transact
for len(*l.items) > 0 {
// Discard stale transactions if found during cleanup
tx := heap.Pop(l.items).(*types.Transaction)
- if _, ok := (*l.all)[tx.Hash()]; !ok {
+ if l.all.Get(tx.Hash()) == nil {
l.stales--
continue
}
@@ -475,7 +476,7 @@ func (l *txPricedList) Underpriced(tx *types.Transaction, local *accountSet) boo
// Discard stale price points if found at the heap start
for len(*l.items) > 0 {
head := []*types.Transaction(*l.items)[0]
- if _, ok := (*l.all)[head.Hash()]; !ok {
+ if l.all.Get(head.Hash()) == nil {
l.stales--
heap.Pop(l.items)
continue
@@ -500,7 +501,7 @@ func (l *txPricedList) Discard(count int, local *accountSet) types.Transactions
for len(*l.items) > 0 && count > 0 {
// Discard stale transactions if found during cleanup
tx := heap.Pop(l.items).(*types.Transaction)
- if _, ok := (*l.all)[tx.Hash()]; !ok {
+ if l.all.Get(tx.Hash()) == nil {
l.stales--
continue
}