diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-07-01 23:59:55 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-09-02 19:12:03 +0800 |
commit | 0ef327bbee79c01a69ba59258acc6ce3a48bc288 (patch) | |
tree | 1d43179977d96c5ca7de85e0727cfa69dbb230ed /eth/api_backend.go | |
parent | 795b70423eac7180ab85b735f64aae9d6a10449d (diff) | |
download | dexon-0ef327bbee79c01a69ba59258acc6ce3a48bc288.tar.gz dexon-0ef327bbee79c01a69ba59258acc6ce3a48bc288.tar.zst dexon-0ef327bbee79c01a69ba59258acc6ce3a48bc288.zip |
core, eth, internal, miner: optimize txpool for quick ops
Diffstat (limited to 'eth/api_backend.go')
-rw-r--r-- | eth/api_backend.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go index e19254374..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]core.TxList, map[common.Address]core.TxList) { +func (b *EthApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) { b.eth.txMu.Lock() defer b.eth.txMu.Unlock() |