Add segid to getsnapshot

This commit is contained in:
blackjok3r
2018-12-11 11:15:17 +08:00
parent 7c60f8032a
commit bf11ecef12

View File

@@ -421,6 +421,7 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type,
} }
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address);
uint32_t komodo_segid32(char *coinaddr);
UniValue CBlockTreeDB::Snapshot(int top) UniValue CBlockTreeDB::Snapshot(int top)
{ {
@@ -518,12 +519,14 @@ UniValue CBlockTreeDB::Snapshot(int top)
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
UniValue addressesSorted(UniValue::VARR); UniValue addressesSorted(UniValue::VARR);
int topN = 0; int topN = 0;
for (std::vector<std::pair<CAmount, std::string>>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) { for (std::vector<std::pair<CAmount, std::string>>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it)
{
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back( make_pair("addr", it->second.c_str() ) ); obj.push_back( make_pair("addr", it->second.c_str() ) );
char amount[32]; char amount[32];
sprintf(amount, "%.8f", (double) it->first / COIN); sprintf(amount, "%.8f", (double) it->first / COIN);
obj.push_back( make_pair("amount", amount) ); obj.push_back( make_pair("amount", amount) );
obj.push_back( make_pair("segid", komodo_segid32(it->second.c_str())));
total += it->first; total += it->first;
addressesSorted.push_back(obj); addressesSorted.push_back(obj);
topN++; topN++;