Skip to content

Commit

Permalink
Fix bug on DsSWTHFrsXV77SwAcMe451kJTwWjwPYjWTM address page
Browse files Browse the repository at this point in the history
  • Loading branch information
dmigwi committed Jul 26, 2018
1 parent 0c48bcc commit b34bb0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions db/dcrpg/pgblockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,12 @@ func (pgb *ChainDB) AddressHistory(address string, N, offset int64,
return addressRows, nil, fmt.Errorf("ReduceAddressHistory failed. len(addressRows) = %d", len(addressRows))
}

// N is a limit on NumFundingTxns, so this checks if we have them all.
if addrInfo.NumFundingTxns < N && offset == 0 && txnType == dbtypes.AddrTxnAll {
// You've got all transactions only when the number of funding transactions
// fetched is equivalent to the number of spending transactions fetched too.
// Or When the total number of fetched transactions is less than the limit
// ,offset is zero and txtype is AddrTxnAll.
if offset == 0 && (addrInfo.NumFundingTxns == addrInfo.NumSpendingTxns ||
(addrInfo.NumTransactions < N && txnType == dbtypes.AddrTxnAll)) {
balanceInfo = explorer.AddressBalance{
Address: address,
NumSpent: addrInfo.NumSpendingTxns,
Expand Down
6 changes: 4 additions & 2 deletions explorer/explorertypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,16 @@ func ReduceAddressHistory(addrHist []*dbtypes.AddressRow) *AddressInfo {

transactions = append(transactions, &tx)
}
var fundingTxs, spendingTxs = int64(len(creditTxns)), int64(len(debitTxns))

return &AddressInfo{
Address: addrHist[0].Address,
Transactions: transactions,
TxnsFunding: creditTxns,
TxnsSpending: debitTxns,
NumFundingTxns: int64(len(creditTxns)),
NumSpendingTxns: int64(len(debitTxns)),
NumTransactions: fundingTxs +spendingTxs,
NumFundingTxns: fundingTxs,
NumSpendingTxns: spendingTxs,
AmountReceived: dcrutil.Amount(received),
AmountSent: dcrutil.Amount(sent),
AmountUnspent: dcrutil.Amount(received - sent),
Expand Down

0 comments on commit b34bb0e

Please sign in to comment.