diff --git a/src/main.cpp b/src/main.cpp index dfebfec4f..11bc3a352 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -592,6 +592,7 @@ UniValue komodo_snapshot() { int64_t total = -1; UniValue result(UniValue::VOBJ); + if (fAddressIndex) { if ( pblocktree != 0 ) { result = pblocktree->Snapshot(); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 198b41090..01bd813e6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -1028,8 +1028,7 @@ UniValue getsnapshot(const UniValue& params, bool fHelp) } result = komodo_snapshot(); if ( result.size() > 0 ) { - // add timestamp, maybe block height? - result.push_back(Pair("time", time(NULL))); + result.push_back(Pair("end_time", time(NULL))); } else { result.push_back(Pair("error", "no addressindex")); } diff --git a/src/txdb.cpp b/src/txdb.cpp index b4ea54f9b..2360ed340 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -405,18 +405,13 @@ extern UniValue CBlockTreeDB::Snapshot() boost::scoped_ptr pcursor(NewIterator()); std::map addressAmounts; UniValue result(UniValue::VOBJ); + result.push_back(Pair("start_time", time(NULL))); //pcursor->SeekToFirst(); pcursor->SeekToLast(); int64_t startingHeight = chainActive.Height(); - // prevent any node updates so we can get a consistent snapshot at this height - // causes coredumps - // LOCK(cs_main); - // does not compile - //LOCK(cs_wallet); - while (pcursor->Valid()) { boost::this_thread::interruption_point(); @@ -476,12 +471,8 @@ extern UniValue CBlockTreeDB::Snapshot() for (std::pair element : sortedSnapshot) { UniValue obj(UniValue::VOBJ); obj.push_back( make_pair("addr", element.first.c_str() ) ); - std::ostringstream strs; - strs << ((double) element.second/COIN); - std::string amount = strs.str(); - - //std::string amount = boost::lexical_cast((double) element.second/COIN); - //sprintf(amount, "%.8f", (double) element.second / COIN); + char amount[32]; + sprintf(amount, "%.8f", (double) element.second / COIN); obj.push_back( make_pair("amount", amount) ); addressesSorted.push_back(obj); }