Skip to content

Commit

Permalink
Review comment applied
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 committed Nov 24, 2024
1 parent 40c941c commit 3bfe8ac
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,24 @@ size_t CBlockTreeDB::findAddressNumWBalance() {
if (pcursor->GetKey(key) && key.first == DB_ADDRESSINDEX && (key.second.type == AddressType::payToPubKeyHash || key.second.type == AddressType::payToExchangeAddress)) {
CAmount nValue;
if (pcursor->GetValue(nValue)) {
auto it = addrMap.find(key.second.hashBytes);
if (it != addrMap.end()) {
it->second += nValue;
if (it->second <= 0)
addrMap.erase(it);
} else {
if (nValue != 0)
addrMap[key.second.hashBytes] = nValue;
CAmount nValue;
// Retrieve the associated value
if (pcursor->GetValue(nValue) && nValue != 0) { // Only process non-zero values
addrMap[key.second.hashBytes] += nValue; // Accumulate balance for the address
}
}
}
pcursor->Next();
}
return addrMap.size();

size_t counter = 0;
for (auto& itr : addrMap) {
if (itr.second > 0) {
++counter;
}
}

return counter;
}

bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey &timestampIndex) {
Expand Down

0 comments on commit 3bfe8ac

Please sign in to comment.