diff --git a/src/main.cpp b/src/main.cpp index d15ff62c0..8dee9bfea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -585,12 +585,12 @@ CBlockTreeDB *pblocktree = NULL; #define KOMODO_ZCASH #include "komodo.h" -int32_t komodo_snapshot() +int64_t komodo_snapshot() { - int32_t num = -1; + int64_t total = -1; if ( pblocktree != 0 ) - num = pblocktree->Snapshot(); - return(num); + total = pblocktree->Snapshot(); + return(total); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 4c4d1958b..b873dc495 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -997,15 +997,15 @@ int32_t komodo_snapshot(); UniValue getsnapshot(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); int32_t num; + UniValue result(UniValue::VOBJ); int64_t total; if ( fHelp || params.size() > 0 ) { throw runtime_error( "getsnapshot\n" ); } - if ( (num= komodo_snapshot()) >= 0 ) - result.push_back(Pair("numaddresses", num)); + if ( (total= komodo_snapshot()) >= 0 ) + result.push_back(Pair("total", (double)total/COIN)); else result.push_back(Pair("error", "no addressindex")); return(result); } diff --git a/src/txdb.cpp b/src/txdb.cpp index d2ffb0b21..72ff85937 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -398,9 +398,9 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); -int32_t CBlockTreeDB::Snapshot() +int64_t CBlockTreeDB::Snapshot() { - char chType; int32_t num = 0; std::string address; + char chType; int64_t total = -1; std::string address; boost::scoped_ptr pcursor(NewIterator()); while (pcursor->Valid()) { @@ -421,7 +421,9 @@ int32_t CBlockTreeDB::Snapshot() ssValue >> nValue; getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); - num++; + if ( total < 0 ) + total = (int64_t)nValue; + else total += (int64_t)nValue; //addressIndex.push_back(make_pair(indexKey, nValue)); pcursor->Next(); } catch (const std::exception& e) { @@ -432,7 +434,7 @@ int32_t CBlockTreeDB::Snapshot() break; } } - return(num); + return(total); } bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey ×tampIndex) {