Skip to content

Commit

Permalink
Remove usused parameter in NewRPCPendingTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
palango committed Feb 15, 2024
1 parent 10a5d97 commit c86947d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context, fullTx *
latest := api.backend.CurrentHeader()
for _, tx := range txs {
if fullTx != nil && *fullTx {
rpcTx := ethapi.NewRPCPendingTransaction(tx, latest, chainConfig, nil)
rpcTx := ethapi.NewRPCPendingTransaction(tx, latest, chainConfig)
notifier.Notify(rpcSub.ID, rpcTx)
} else {
notifier.Notify(rpcSub.ID, tx.Hash())
Expand Down
29 changes: 9 additions & 20 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,19 @@ func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*RPCTransac
}
pending, queue := s.b.TxPoolContent()
curHeader := s.b.CurrentHeader()
baseFeeFn := func(feeCurrency *common.Address) (*big.Int, error) {
return s.b.CurrentGasPriceMinimum(context.Background(), feeCurrency)
}
// Flatten the pending transactions
for account, txs := range pending {
dump := make(map[string]*RPCTransaction)
for _, tx := range txs {
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig(), baseFeeFn)
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
}
content["pending"][account.Hex()] = dump
}
// Flatten the queued transactions
for account, txs := range queue {
dump := make(map[string]*RPCTransaction)
for _, tx := range txs {
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig(), baseFeeFn)
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
}
content["queued"][account.Hex()] = dump
}
Expand All @@ -176,18 +173,15 @@ func (s *PublicTxPoolAPI) ContentFrom(addr common.Address) map[string]map[string

// Build the pending transactions
dump := make(map[string]*RPCTransaction, len(pending))
baseFeeFn := func(feeCurrency *common.Address) (*big.Int, error) {
return s.b.CurrentGasPriceMinimum(context.Background(), feeCurrency)
}
for _, tx := range pending {
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig(), baseFeeFn)
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())
}
content["pending"] = dump

// Build the queued transactions
dump = make(map[string]*RPCTransaction, len(queue))
for _, tx := range queue {
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig(), baseFeeFn)
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig())

}
content["queued"] = dump
Expand Down Expand Up @@ -1357,8 +1351,9 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
}

// NewRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig, baseFeeFn func(*common.Address) (*big.Int, error)) *RPCTransaction {
return newRPCTransaction(tx, common.Hash{}, 0, 0, baseFeeFn, false)
func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction {
// With `inABlock` set to `false, `baseFeeFn` is never called
return newRPCTransaction(tx, common.Hash{}, 0, 0, nil, false)
}

// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
Expand Down Expand Up @@ -1594,10 +1589,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, has
}
// No finalized transaction, try to retrieve it from the pool
if tx := s.b.GetPoolTransaction(hash); tx != nil {
baseFeeFn := func(feeCurrency *common.Address) (*big.Int, error) {
return s.b.CurrentGasPriceMinimum(context.Background(), tx.FeeCurrency())
}
return NewRPCPendingTransaction(tx, s.b.CurrentHeader(), s.b.ChainConfig(), baseFeeFn), nil
return NewRPCPendingTransaction(tx, s.b.CurrentHeader(), s.b.ChainConfig()), nil
}

// Transaction unknown, return as such
Expand Down Expand Up @@ -1898,13 +1890,10 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err
}
curHeader := s.b.CurrentHeader()
transactions := make([]*RPCTransaction, 0, len(pending))
baseFeeFn := func(feeCurrency *common.Address) (*big.Int, error) {
return s.b.CurrentGasPriceMinimum(context.Background(), feeCurrency)
}
for _, tx := range pending {
from, _ := types.Sender(s.signer, tx)
if _, exists := accounts[from]; exists {
transactions = append(transactions, NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig(), baseFeeFn))
transactions = append(transactions, NewRPCPendingTransaction(tx, curHeader, s.b.ChainConfig()))
}
}
return transactions, nil
Expand Down

0 comments on commit c86947d

Please sign in to comment.