From 39ae2f13d9fc9e535705a8e878f63a41f1fc6aa9 Mon Sep 17 00:00:00 2001 From: sidenaio <50700001+sidenaio@users.noreply.github.com> Date: Wed, 25 Aug 2021 09:58:41 +0500 Subject: [PATCH] Add mempool nonce into response of getBalance rpc method (#779) --- api/dna_api.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/dna_api.go b/api/dna_api.go index 773d0ee2..0ea97d03 100644 --- a/api/dna_api.go +++ b/api/dna_api.go @@ -50,9 +50,10 @@ func (api *DnaApi) GetCoinbaseAddr() common.Address { } type Balance struct { - Stake decimal.Decimal `json:"stake"` - Balance decimal.Decimal `json:"balance"` - Nonce uint32 `json:"nonce"` + Stake decimal.Decimal `json:"stake"` + Balance decimal.Decimal `json:"balance"` + Nonce uint32 `json:"nonce"` + MempoolNonce uint32 `json:"mempoolNonce"` } func (api *DnaApi) GetBalance(address common.Address) Balance { @@ -64,9 +65,10 @@ func (api *DnaApi) GetBalance(address common.Address) Balance { } return Balance{ - Stake: blockchain.ConvertToFloat(state.State.GetStakeBalance(address)), - Balance: blockchain.ConvertToFloat(state.State.GetBalance(address)), - Nonce: nonce, + Stake: blockchain.ConvertToFloat(state.State.GetStakeBalance(address)), + Balance: blockchain.ConvertToFloat(state.State.GetBalance(address)), + Nonce: nonce, + MempoolNonce: state.NonceCache.GetNonce(address, currentEpoch), } }