aboutsummaryrefslogtreecommitdiffstats
path: root/core/tx_list.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-07-05 21:51:55 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-07-05 21:51:55 +0800
commit48ee7f9de7da0455b80ee09f498dbce54127103a (patch)
tree1e16769e36f34efd5a22283b06e57e551ac948a0 /core/tx_list.go
parenta633a2d7ea8aadb1d435679449d002de880fab30 (diff)
downloadgo-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.tar
go-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.tar.gz
go-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.tar.bz2
go-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.tar.lz
go-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.tar.xz
go-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.tar.zst
go-tangerine-48ee7f9de7da0455b80ee09f498dbce54127103a.zip
core, eth, les: polish txpool API around local/remote txs
Diffstat (limited to 'core/tx_list.go')
-rw-r--r--core/tx_list.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/core/tx_list.go b/core/tx_list.go
index e12af4a89..4593943be 100644
--- a/core/tx_list.go
+++ b/core/tx_list.go
@@ -420,7 +420,7 @@ 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 *accountSet) types.Transactions {
drop := make(types.Transactions, 0, 128) // Remote underpriced transactions to drop
@@ -429,9 +429,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)
-
- 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 *accountSet) types.Transact
break
}
// Non stale transaction found, discard unless local
- if local.contains(tx) {
+ if local.containsTx(tx) {
save = append(save, tx)
} else {
drop = append(drop, tx)
@@ -456,7 +454,7 @@ func (l *txPricedList) Cap(threshold *big.Int, local *accountSet) types.Transact
// lowest priced transaction currently being tracked.
func (l *txPricedList) Underpriced(tx *types.Transaction, local *accountSet) bool {
// Local transactions cannot be underpriced
- if local.contains(tx) {
+ if local.containsTx(tx) {
return false
}
// Discard stale price points if found at the heap start
@@ -487,14 +485,12 @@ 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)
-
- 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(tx) {
+ if local.containsTx(tx) {
save = append(save, tx)
} else {
drop = append(drop, tx)