Merge pull request #1323 from MyHush/snapshot_fix

Filter out amount=0 UTXOs from getsnapshot results
This commit is contained in:
jl777
2019-03-09 16:01:18 -11:00
committed by GitHub

View File

@@ -491,27 +491,31 @@ UniValue CBlockTreeDB::Snapshot(int top)
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
std::map <std::string, int>::iterator ignored = ignoredMap.find(address); if (nValue > 0) {
if (ignored != ignoredMap.end()) { std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
fprintf(stderr,"ignoring %s\n", address.c_str()); if (ignored != ignoredMap.end()) {
ignoredAddresses++; fprintf(stderr,"ignoring %s\n", address.c_str());
continue; ignoredAddresses++;
} continue;
}
std::map <std::string, CAmount>::iterator pos = addressAmounts.find(address); std::map <std::string, CAmount>::iterator pos = addressAmounts.find(address);
if (pos == addressAmounts.end()) { if (pos == addressAmounts.end()) {
// insert new address + utxo amount // insert new address + utxo amount
//fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue);
addressAmounts[address] = nValue; addressAmounts[address] = nValue;
totalAddresses++; totalAddresses++;
} else {
// update unspent tally for this address
//fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue);
addressAmounts[address] += nValue;
}
//fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
// total += nValue;
utxos++;
} else { } else {
// update unspent tally for this address fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str());
//fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue);
addressAmounts[address] += nValue;
} }
//fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
// total += nValue;
utxos++;
} catch (const std::exception& e) { } catch (const std::exception& e) {
fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what()); fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what());
break; break;