aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYondon Fu <yondon.fu@gmail.com>2019-01-07 16:47:11 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-01-07 16:47:11 +0800
commite05d46807525f76dab83f84e9dfc9e4537398641 (patch)
tree31d6b8d1a433bb3c71ec4ad24ec333a92532a79f
parentaca588a8e434cd0409c44d55b6009fb74e913537 (diff)
downloaddexon-e05d46807525f76dab83f84e9dfc9e4537398641.tar
dexon-e05d46807525f76dab83f84e9dfc9e4537398641.tar.gz
dexon-e05d46807525f76dab83f84e9dfc9e4537398641.tar.bz2
dexon-e05d46807525f76dab83f84e9dfc9e4537398641.tar.lz
dexon-e05d46807525f76dab83f84e9dfc9e4537398641.tar.xz
dexon-e05d46807525f76dab83f84e9dfc9e4537398641.tar.zst
dexon-e05d46807525f76dab83f84e9dfc9e4537398641.zip
internal/ethapi: ask transaction pool for pending nonce (#15794)
-rw-r--r--internal/ethapi/api.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 656555b3b..73b629bd9 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -1074,6 +1074,15 @@ 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) {
+ // Ask transaction pool for the nonce which includes pending transactions
+ if blockNr == rpc.PendingBlockNumber {
+ nonce, err := s.b.GetPoolNonce(ctx, address)
+ if err != nil {
+ return nil, err
+ }
+ return (*hexutil.Uint64)(&nonce), nil
+ }
+ // Resolve block number and use its state to ask for the nonce
state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
if state == nil || err != nil {
return nil, err