From 1fbea1eeb71062477d104b4def4c367cc5407de8 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Tue, 13 Nov 2018 15:26:21 +0800 Subject: dex: return correct pending nonce (#14) We need to return the correct pending nonce (include those in the tx pool). Also, StateAndHeaderByNumber is also fixed to use pending block. --- internal/ethapi/api.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'internal/ethapi') diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d1563db6e..e3c7f64d6 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1078,6 +1078,13 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx cont // GetTransactionCount returns the number of transactions the given address has sent for the given block number func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error) { + if blockNr == rpc.PendingBlockNumber { + nonce, err := s.b.GetPoolNonce(ctx, address) + if err != nil { + return nil, err + } + return (*hexutil.Uint64)(&nonce), nil + } state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr) if state == nil || err != nil { return nil, err -- cgit v1.2.3