trace: retrieve from txpool

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2024-10-03 20:45:00 +08:00
parent 7c1d2467db
commit 36c98a31e2
2 changed files with 7 additions and 1 deletions

View file

@ -73,6 +73,7 @@ type BlockEvent struct {
// Backend interface provides the common API services (that are provided by
// both full and light clients) with access to necessary functions.
type Backend interface {
CurrentHeader() *types.Header
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

View file

@ -18,7 +18,12 @@ type ethAPI struct {
func (n *ethAPI) GetTransactionBySenderAndNonce(ctx context.Context, sender common.Address, nonce hexutil.Uint) (*ethapi.RPCTransaction, error) {
// TODO:
// 1. return nil if sender is a contract
// 2. check with txpool first
// Retrieve from txpool first
if tx := n.backend.GetPoolTransactionBySenderAndNonce(sender, uint64(nonce)); tx != nil {
return ethapi.NewRPCPendingTransaction(tx, n.backend.CurrentHeader(), n.backend.ChainConfig()), nil
}
txHash, err := n.live.kvdb.Get(append(sender.Bytes(), encodeNumber(uint64(nonce))...))
if err != nil {
return nil, nil