Browse Source

bug fix

pull/27/head
blackjok3r 5 years ago
parent
commit
9802d350aa
  1. 2
      src/rpc/misc.cpp
  2. 6
      src/txdb.cpp

2
src/rpc/misc.cpp

@ -1383,7 +1383,7 @@ UniValue getsnapshot(const UniValue& params, bool fHelp)
if (params.size() > 0 && !params[0].isNull()) {
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");
top = -1;
}

6
src/txdb.cpp

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

Loading…
Cancel
Save