Skip to content

Commit e05d468

Browse files
yondonfukaralabe
authored andcommitted
internal/ethapi: ask transaction pool for pending nonce (#15794)
1 parent aca588a commit e05d468

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎internal/ethapi/api.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,15 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx cont
10741074

10751075
// GetTransactionCount returns the number of transactions the given address has sent for the given block number
10761076
func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error) {
1077+
// Ask transaction pool for the nonce which includes pending transactions
1078+
if blockNr == rpc.PendingBlockNumber {
1079+
nonce, err := s.b.GetPoolNonce(ctx, address)
1080+
if err != nil {
1081+
return nil, err
1082+
}
1083+
return (*hexutil.Uint64)(&nonce), nil
1084+
}
1085+
// Resolve block number and use its state to ask for the nonce
10771086
state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
10781087
if state == nil || err != nil {
10791088
return nil, err

0 commit comments

Comments
 (0)