Skip to content

Commit

Permalink
Merge pull request #484 from imterryyy/fix/tx-pool-nonce
Browse files Browse the repository at this point in the history
feat(internal/ethapi/api): Ask transaction pool for the nonce which includes pending transactions
  • Loading branch information
tungng98 authored Jan 7, 2025
2 parents 9f5d1b7 + 8f286f9 commit 926bb45
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,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
}

state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
if state == nil || err != nil {
return nil, err
Expand Down

0 comments on commit 926bb45

Please sign in to comment.