Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: remove unused error from TxPool.Pending #23720

Merged
merged 3 commits into from Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/tx_pool.go
Expand Up @@ -533,7 +533,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()

Expand All @@ -554,7 +554,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.
Expand Down
4 changes: 0 additions & 4 deletions core/tx_pool_test.go
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions eth/api_backend.go
Expand Up @@ -236,10 +236,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...)
Expand Down
5 changes: 1 addition & 4 deletions eth/catalyst/api.go
Expand Up @@ -128,10 +128,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 {
Expand Down
2 changes: 1 addition & 1 deletion eth/handler.go
Expand Up @@ -66,7 +66,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.
Expand Down
4 changes: 2 additions & 2 deletions eth/handler_test.go
Expand Up @@ -91,7 +91,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()

Expand All @@ -103,7 +103,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
Expand Down
2 changes: 1 addition & 1 deletion eth/sync.go
Expand Up @@ -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...)
}
Expand Down
6 changes: 1 addition & 5 deletions miner/worker.go
Expand Up @@ -977,11 +977,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.
Expand Down