aboutsummaryrefslogtreecommitdiffstats
path: root/eth/helper_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-10-10 22:19:05 +0800
committerGitHub <noreply@github.com>2016-10-10 22:19:05 +0800
commit5a6008e004a6611d7a478495d083eaf26e52c5f1 (patch)
tree9986a1f364306b8a09234125d623d99b4c56d098 /eth/helper_test.go
parent4fced0972d9bf2802cb9c3eb16cedc79c9dd60a1 (diff)
parentabaa56fea59f38fcea4fb6a7537074dbe845cf51 (diff)
downloadgo-tangerine-1.4.17.tar
go-tangerine-1.4.17.tar.gz
go-tangerine-1.4.17.tar.bz2
go-tangerine-1.4.17.tar.lz
go-tangerine-1.4.17.tar.xz
go-tangerine-1.4.17.tar.zst
go-tangerine-1.4.17.zip
Merge pull request #3116 from fjl/release/1.4v1.4.17
Backport TxPool limits to release/1.4
Diffstat (limited to 'eth/helper_test.go')
-rw-r--r--eth/helper_test.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/eth/helper_test.go b/eth/helper_test.go
index 28ff69b17..732fe89ee 100644
--- a/eth/helper_test.go
+++ b/eth/helper_test.go
@@ -23,6 +23,7 @@ import (
"crypto/ecdsa"
"crypto/rand"
"math/big"
+ "sort"
"sync"
"testing"
@@ -89,9 +90,9 @@ type testTxPool struct {
lock sync.RWMutex // Protects the transaction pool
}
-// AddTransactions appends a batch of transactions to the pool, and notifies any
+// AddBatch appends a batch of transactions to the pool, and notifies any
// listeners if the addition channel is non nil
-func (p *testTxPool) AddTransactions(txs []*types.Transaction) {
+func (p *testTxPool) AddBatch(txs []*types.Transaction) {
p.lock.Lock()
defer p.lock.Unlock()
@@ -101,15 +102,20 @@ func (p *testTxPool) AddTransactions(txs []*types.Transaction) {
}
}
-// GetTransactions returns all the transactions known to the pool
-func (p *testTxPool) GetTransactions() types.Transactions {
+// Pending returns all the transactions known to the pool
+func (p *testTxPool) Pending() map[common.Address]types.Transactions {
p.lock.RLock()
defer p.lock.RUnlock()
- txs := make([]*types.Transaction, len(p.pool))
- copy(txs, p.pool)
-
- return txs
+ batches := make(map[common.Address]types.Transactions)
+ for _, tx := range p.pool {
+ from, _ := tx.From()
+ batches[from] = append(batches[from], tx)
+ }
+ for _, batch := range batches {
+ sort.Sort(types.TxByNonce(batch))
+ }
+ return batches
}
// newTestTransaction create a new dummy transaction.