This commit is contained in:
blackjok3r
2019-05-04 01:55:33 +08:00
parent aa32b1f963
commit 9802d350aa
2 changed files with 5 additions and 3 deletions

View File

@@ -1383,7 +1383,7 @@ UniValue getsnapshot(const UniValue& params, bool fHelp)
if (params.size() > 0 && !params[0].isNull()) { if (params.size() > 0 && !params[0].isNull()) {
top = atoi(params[0].get_str().c_str()); top = atoi(params[0].get_str().c_str());
if (top <= 0) if (top < 0)
//throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); //throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer");
top = -1; top = -1;
} }

View File

@@ -481,6 +481,8 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
try { try {
CAmount nValue; CAmount nValue;
iter->GetValue(nValue); iter->GetValue(nValue);
if ( nValue == 0 )
continue;
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
if ( indexKey.type == 3 ) if ( indexKey.type == 3 )
{ {
@@ -566,9 +568,9 @@ UniValue CBlockTreeDB::Snapshot(int top)
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
UniValue addressesSorted(UniValue::VARR); UniValue addressesSorted(UniValue::VARR);
result.push_back(Pair("start_time", (int) time(NULL))); result.push_back(Pair("start_time", (int) time(NULL)));
if ( (vAddressSnapshot.size() > 0 && top < 0) || (Snapshot2(addressAmounts,&result) && top > 0) ) if ( (vAddressSnapshot.size() > 0 && top < 0) || (Snapshot2(addressAmounts,&result) && top >= 0) )
{ {
if ( top > 0 ) if ( top > -1 )
{ {
for (std::pair<std::string, CAmount> element : addressAmounts) for (std::pair<std::string, CAmount> element : addressAmounts)
vaddr.push_back( make_pair(element.second, element.first) ); vaddr.push_back( make_pair(element.second, element.first) );