diff --git a/core/tx_pool.go b/core/tx_pool.go index ce0f5194de..a1a9655e46 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -569,7 +569,7 @@ func (pool *TxPool) ContentFrom(addr common.Address) (types.Transactions, types. // The enforceTips parameter can be used to do an extra filtering on the pending // transactions and only return those whose **effective** tip is large enough in // the next pending execution environment. -func (pool *TxPool) Pending(enforceTips bool) (map[common.Address]types.Transactions, error) { +func (pool *TxPool) Pending(enforceTips bool) map[common.Address]types.Transactions { pool.mu.Lock() defer pool.mu.Unlock() @@ -590,7 +590,7 @@ func (pool *TxPool) Pending(enforceTips bool) (map[common.Address]types.Transact pending[addr] = txs } } - return pending, nil + return pending } // Locals retrieves the accounts currently considered local by the pool. diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index b309deefc2..fc5d82c784 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -272,10 +272,6 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) { trigger = true <-pool.requestReset(nil, nil) - _, err := pool.Pending(false) - if err != nil { - t.Fatalf("Could not fetch pending transactions: %v", err) - } nonce = pool.Nonce(address) if nonce != 2 { t.Fatalf("Invalid nonce, want 2, got %d", nonce) diff --git a/eth/api_backend.go b/eth/api_backend.go index 087cd3cf1a..ce8ddd05de 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -298,10 +298,7 @@ func (b *EthApiBackend) SendLendingTx(ctx context.Context, signedTx *types.Lendi } func (b *EthApiBackend) GetPoolTransactions() (types.Transactions, error) { - pending, err := b.eth.txPool.Pending(false) - if err != nil { - return nil, err - } + pending := b.eth.txPool.Pending(false) var txs types.Transactions for _, batch := range pending { txs = append(txs, batch...) diff --git a/eth/helper_test.go b/eth/helper_test.go index de175bbcee..0b793d09bc 100644 --- a/eth/helper_test.go +++ b/eth/helper_test.go @@ -111,7 +111,7 @@ func (p *testTxPool) AddRemotes(txs []*types.Transaction) []error { } // Pending returns all the transactions known to the pool -func (p *testTxPool) Pending(enforceTips bool) (map[common.Address]types.Transactions, error) { +func (p *testTxPool) Pending(enforceTips bool) map[common.Address]types.Transactions { p.lock.RLock() defer p.lock.RUnlock() @@ -123,7 +123,7 @@ func (p *testTxPool) Pending(enforceTips bool) (map[common.Address]types.Transac for _, batch := range batches { sort.Sort(types.TxByNonce(batch)) } - return batches, nil + return batches } func (p *testTxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription { diff --git a/eth/protocol.go b/eth/protocol.go index 3876133e83..6cba0e1eba 100644 --- a/eth/protocol.go +++ b/eth/protocol.go @@ -108,7 +108,7 @@ type txPool interface { // Pending should return pending transactions. // The slice should be modifiable by the caller. - Pending(enforceTips bool) (map[common.Address]types.Transactions, error) + Pending(enforceTips bool) map[common.Address]types.Transactions // SubscribeNewTxsEvent should return an event subscription of // NewTxsEvent and send events to the given channel. diff --git a/eth/sync.go b/eth/sync.go index 76edb614fb..5a0ea512f5 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -45,7 +45,7 @@ type txsync struct { // syncTransactions starts sending all currently pending transactions to the given peer. func (pm *ProtocolManager) syncTransactions(p *peer) { var txs types.Transactions - pending, _ := pm.txpool.Pending(false) + pending := pm.txpool.Pending(false) for _, batch := range pending { txs = append(txs, batch...) } diff --git a/miner/worker.go b/miner/worker.go index c076518a60..73aecd9fe7 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -679,11 +679,7 @@ func (w *worker) commitNewWork() { log.Error("[commitNewWork] fail to check if block is epoch switch block when fetching pending transactions", "BlockNum", header.Number, "Hash", header.Hash()) } if !isEpochSwitchBlock { - pending, err := w.eth.TxPool().Pending(true) - if err != nil { - log.Error("Failed to fetch pending transactions", "err", err) - return - } + pending := w.eth.TxPool().Pending(true) txs, specialTxs = types.NewTransactionsByPriceAndNonce(w.current.signer, pending, signers, feeCapacity) } }