diff --git a/core/tx_pool.go b/core/tx_pool.go index 23255c6d8e8f3..33614617615be 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -535,7 +535,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() @@ -556,7 +556,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 9b5208de3aa70..1406c8df02645 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -255,10 +255,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 41ed0760b2b87..cdfb4fd6101bf 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -245,10 +245,7 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) } 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/catalyst/api.go b/eth/catalyst/api.go index ea5414bd4c8a7..3913da757222f 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -126,10 +126,7 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD time.Sleep(wait) } - pending, err := pool.Pending(true) - if err != nil { - return nil, err - } + pending := pool.Pending(true) coinbase, err := api.eth.Etherbase() if err != nil { diff --git a/eth/handler.go b/eth/handler.go index 1f9532adb39a5..ae9b52e4435d7 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -67,7 +67,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/handler_test.go b/eth/handler_test.go index b8e29304d52c1..ff60b1b7a0886 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -96,7 +96,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() @@ -108,7 +108,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 } // SubscribeNewTxsEvent should return an event subscription of NewTxsEvent and diff --git a/eth/sync.go b/eth/sync.go index d156c144ea35e..aaac6bef90543 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -43,7 +43,7 @@ func (h *handler) syncTransactions(p *eth.Peer) { // // TODO(karalabe): Figure out if we could get away with random order somehow var txs types.Transactions - pending, _ := h.txpool.Pending(false) + pending := h.txpool.Pending(false) for _, batch := range pending { txs = append(txs, batch...) } diff --git a/miner/worker.go b/miner/worker.go index 38be86830f0d9..7fb63c54b7263 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -995,11 +995,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) } // Fill the block with all available pending transactions. - 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) // Short circuit if there is no available pending transactions. // But if we disable empty precommit already, ignore it. Since // empty block is necessary to keep the liveness of the network.