mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
trace: retrieve from txpool
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
7c1d2467db
commit
36c98a31e2
2 changed files with 7 additions and 1 deletions
|
|
@ -73,6 +73,7 @@ type BlockEvent struct {
|
||||||
// Backend interface provides the common API services (that are provided by
|
// Backend interface provides the common API services (that are provided by
|
||||||
// both full and light clients) with access to necessary functions.
|
// both full and light clients) with access to necessary functions.
|
||||||
type Backend interface {
|
type Backend interface {
|
||||||
|
CurrentHeader() *types.Header
|
||||||
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
|
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
|
||||||
HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
|
HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
|
||||||
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
|
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,12 @@ type ethAPI struct {
|
||||||
func (n *ethAPI) GetTransactionBySenderAndNonce(ctx context.Context, sender common.Address, nonce hexutil.Uint) (*ethapi.RPCTransaction, error) {
|
func (n *ethAPI) GetTransactionBySenderAndNonce(ctx context.Context, sender common.Address, nonce hexutil.Uint) (*ethapi.RPCTransaction, error) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// 1. return nil if sender is a contract
|
// 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))...))
|
txHash, err := n.live.kvdb.Get(append(sender.Bytes(), encodeNumber(uint64(nonce))...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue