Include start_time+end_time and correctly format amount
This commit is contained in:
@@ -592,6 +592,7 @@ UniValue komodo_snapshot()
|
|||||||
{
|
{
|
||||||
int64_t total = -1;
|
int64_t total = -1;
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
|
|
||||||
if (fAddressIndex) {
|
if (fAddressIndex) {
|
||||||
if ( pblocktree != 0 ) {
|
if ( pblocktree != 0 ) {
|
||||||
result = pblocktree->Snapshot();
|
result = pblocktree->Snapshot();
|
||||||
|
|||||||
@@ -1028,8 +1028,7 @@ UniValue getsnapshot(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
result = komodo_snapshot();
|
result = komodo_snapshot();
|
||||||
if ( result.size() > 0 ) {
|
if ( result.size() > 0 ) {
|
||||||
// add timestamp, maybe block height?
|
result.push_back(Pair("end_time", time(NULL)));
|
||||||
result.push_back(Pair("time", time(NULL)));
|
|
||||||
} else {
|
} else {
|
||||||
result.push_back(Pair("error", "no addressindex"));
|
result.push_back(Pair("error", "no addressindex"));
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/txdb.cpp
15
src/txdb.cpp
@@ -405,18 +405,13 @@ extern UniValue CBlockTreeDB::Snapshot()
|
|||||||
boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator());
|
boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator());
|
||||||
std::map <std::string, CAmount> addressAmounts;
|
std::map <std::string, CAmount> addressAmounts;
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
|
result.push_back(Pair("start_time", time(NULL)));
|
||||||
|
|
||||||
//pcursor->SeekToFirst();
|
//pcursor->SeekToFirst();
|
||||||
pcursor->SeekToLast();
|
pcursor->SeekToLast();
|
||||||
|
|
||||||
int64_t startingHeight = chainActive.Height();
|
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())
|
while (pcursor->Valid())
|
||||||
{
|
{
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
@@ -476,12 +471,8 @@ extern UniValue CBlockTreeDB::Snapshot()
|
|||||||
for (std::pair<std::string, CAmount> element : sortedSnapshot) {
|
for (std::pair<std::string, CAmount> element : sortedSnapshot) {
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.push_back( make_pair("addr", element.first.c_str() ) );
|
obj.push_back( make_pair("addr", element.first.c_str() ) );
|
||||||
std::ostringstream strs;
|
char amount[32];
|
||||||
strs << ((double) element.second/COIN);
|
sprintf(amount, "%.8f", (double) element.second / COIN);
|
||||||
std::string amount = strs.str();
|
|
||||||
|
|
||||||
//std::string amount = boost::lexical_cast<std::string>((double) element.second/COIN);
|
|
||||||
//sprintf(amount, "%.8f", (double) element.second / COIN);
|
|
||||||
obj.push_back( make_pair("amount", amount) );
|
obj.push_back( make_pair("amount", amount) );
|
||||||
addressesSorted.push_back(obj);
|
addressesSorted.push_back(obj);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user