aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorWei-Ning Huang <aitjcize@gmail.com>2018-11-13 15:26:21 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 20:54:27 +0800
commit1fbea1eeb71062477d104b4def4c367cc5407de8 (patch)
treec95c74e5dfbabdcb245c1753229a92b8ce25d4fe /internal
parent2029c52f5a683f8135dba829495981a128412e40 (diff)
downloaddexon-1fbea1eeb71062477d104b4def4c367cc5407de8.tar
dexon-1fbea1eeb71062477d104b4def4c367cc5407de8.tar.gz
dexon-1fbea1eeb71062477d104b4def4c367cc5407de8.tar.bz2
dexon-1fbea1eeb71062477d104b4def4c367cc5407de8.tar.lz
dexon-1fbea1eeb71062477d104b4def4c367cc5407de8.tar.xz
dexon-1fbea1eeb71062477d104b4def4c367cc5407de8.tar.zst
dexon-1fbea1eeb71062477d104b4def4c367cc5407de8.zip
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.
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go7
1 files changed, 7 insertions, 0 deletions
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