aboutsummaryrefslogtreecommitdiffstats
path: root/eth/api_backend.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-09-02 19:44:23 +0800
committerGitHub <noreply@github.com>2016-09-02 19:44:23 +0800
commita42b7355f40fbc58893ca074db818d461083912c (patch)
tree1217ca54edf4fc72734dc00bf09d4a827106bd82 /eth/api_backend.go
parent49227f65ff5ae42d47dfb65eaf88d38790543b06 (diff)
parentb4a52513915d5a39ac055fc38cafed70098eb698 (diff)
downloaddexon-a42b7355f40fbc58893ca074db818d461083912c.tar
dexon-a42b7355f40fbc58893ca074db818d461083912c.tar.gz
dexon-a42b7355f40fbc58893ca074db818d461083912c.tar.bz2
dexon-a42b7355f40fbc58893ca074db818d461083912c.tar.lz
dexon-a42b7355f40fbc58893ca074db818d461083912c.tar.xz
dexon-a42b7355f40fbc58893ca074db818d461083912c.tar.zst
dexon-a42b7355f40fbc58893ca074db818d461083912c.zip
Merge pull request #2742 from karalabe/tx-spam-protection
Transaction pool optimizations
Diffstat (limited to 'eth/api_backend.go')
-rw-r--r--eth/api_backend.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go
index efcdb3361..4f8f06529 100644
--- a/eth/api_backend.go
+++ b/eth/api_backend.go
@@ -118,21 +118,25 @@ func (b *EthApiBackend) RemoveTx(txHash common.Hash) {
b.eth.txMu.Lock()
defer b.eth.txMu.Unlock()
- b.eth.txPool.RemoveTx(txHash)
+ b.eth.txPool.Remove(txHash)
}
func (b *EthApiBackend) GetPoolTransactions() types.Transactions {
b.eth.txMu.Lock()
defer b.eth.txMu.Unlock()
- return b.eth.txPool.GetTransactions()
+ var txs types.Transactions
+ for _, batch := range b.eth.txPool.Pending() {
+ txs = append(txs, batch...)
+ }
+ return txs
}
-func (b *EthApiBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction {
+func (b *EthApiBackend) GetPoolTransaction(hash common.Hash) *types.Transaction {
b.eth.txMu.Lock()
defer b.eth.txMu.Unlock()
- return b.eth.txPool.GetTransaction(txHash)
+ return b.eth.txPool.Get(hash)
}
func (b *EthApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) {
@@ -149,7 +153,7 @@ func (b *EthApiBackend) Stats() (pending int, queued int) {
return b.eth.txPool.Stats()
}
-func (b *EthApiBackend) TxPoolContent() (map[common.Address]map[uint64][]*types.Transaction, map[common.Address]map[uint64][]*types.Transaction) {
+func (b *EthApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) {
b.eth.txMu.Lock()
defer b.eth.txMu.Unlock()