Add segid to getsnapshot
This commit is contained in:
71
src/txdb.cpp
71
src/txdb.cpp
@@ -45,7 +45,7 @@ static const char DB_LAST_BLOCK = 'l';
|
|||||||
CCoinsViewDB::CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / dbName, nCacheSize, fMemory, fWipe) {
|
CCoinsViewDB::CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / dbName, nCacheSize, fMemory, fWipe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe)
|
CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ uint256 CCoinsViewDB::GetBestBlock() const {
|
|||||||
|
|
||||||
uint256 CCoinsViewDB::GetBestAnchor(ShieldedType type) const {
|
uint256 CCoinsViewDB::GetBestAnchor(ShieldedType type) const {
|
||||||
uint256 hashBestAnchor;
|
uint256 hashBestAnchor;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPROUT:
|
case SPROUT:
|
||||||
if (!db.Read(DB_BEST_SPROUT_ANCHOR, hashBestAnchor))
|
if (!db.Read(DB_BEST_SPROUT_ANCHOR, hashBestAnchor))
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -433,23 +434,23 @@ UniValue CBlockTreeDB::Snapshot(int top)
|
|||||||
result.push_back(Pair("start_time", (int) time(NULL)));
|
result.push_back(Pair("start_time", (int) time(NULL)));
|
||||||
|
|
||||||
std::map <std::string,int> ignoredMap = {
|
std::map <std::string,int> ignoredMap = {
|
||||||
{"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1},
|
{"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1},
|
||||||
{"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1},
|
{"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1},
|
||||||
{"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1},
|
{"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1},
|
||||||
{"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1},
|
{"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1},
|
||||||
{"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1},
|
{"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1},
|
||||||
{"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1},
|
{"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1},
|
||||||
{"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1},
|
{"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1},
|
||||||
{"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1},
|
{"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1},
|
||||||
{"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1},
|
{"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1},
|
||||||
{"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1},
|
{"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1},
|
||||||
{"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1},
|
{"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1},
|
||||||
{"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1},
|
{"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1},
|
||||||
{"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1},
|
{"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1},
|
||||||
{"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1},
|
{"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1},
|
||||||
{"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1},
|
{"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1},
|
||||||
{"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1},
|
{"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1},
|
||||||
{"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey
|
{"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey
|
||||||
};
|
};
|
||||||
|
|
||||||
int64_t startingHeight = chainActive.Height();
|
int64_t startingHeight = chainActive.Height();
|
||||||
@@ -511,29 +512,31 @@ UniValue CBlockTreeDB::Snapshot(int top)
|
|||||||
//fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses);
|
//fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses);
|
||||||
|
|
||||||
for (std::pair<std::string, CAmount> element : addressAmounts) {
|
for (std::pair<std::string, CAmount> element : addressAmounts) {
|
||||||
vaddr.push_back( make_pair(element.second, element.first) );
|
vaddr.push_back( make_pair(element.second, element.first) );
|
||||||
}
|
}
|
||||||
std::sort(vaddr.rbegin(), vaddr.rend());
|
std::sort(vaddr.rbegin(), vaddr.rend());
|
||||||
|
|
||||||
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);
|
{
|
||||||
obj.push_back( make_pair("addr", it->second.c_str() ) );
|
UniValue obj(UniValue::VOBJ);
|
||||||
char amount[32];
|
obj.push_back( make_pair("addr", it->second.c_str() ) );
|
||||||
sprintf(amount, "%.8f", (double) it->first / COIN);
|
char amount[32];
|
||||||
obj.push_back( make_pair("amount", amount) );
|
sprintf(amount, "%.8f", (double) it->first / COIN);
|
||||||
total += it->first;
|
obj.push_back( make_pair("amount", amount) );
|
||||||
addressesSorted.push_back(obj);
|
obj.push_back( make_pair("segid", komodo_segid32(it->second.c_str())));
|
||||||
topN++;
|
total += it->first;
|
||||||
// If requested, only show top N addresses in output JSON
|
addressesSorted.push_back(obj);
|
||||||
if (top == topN)
|
topN++;
|
||||||
break;
|
// If requested, only show top N addresses in output JSON
|
||||||
|
if (top == topN)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top)
|
if (top)
|
||||||
totalAddresses = top;
|
totalAddresses = top;
|
||||||
|
|
||||||
if (totalAddresses > 0) {
|
if (totalAddresses > 0) {
|
||||||
// Array of all addreses with balances
|
// Array of all addreses with balances
|
||||||
@@ -670,7 +673,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
pindexNew->nCachedBranchId = diskindex.nCachedBranchId;
|
pindexNew->nCachedBranchId = diskindex.nCachedBranchId;
|
||||||
pindexNew->nTx = diskindex.nTx;
|
pindexNew->nTx = diskindex.nTx;
|
||||||
pindexNew->nSproutValue = diskindex.nSproutValue;
|
pindexNew->nSproutValue = diskindex.nSproutValue;
|
||||||
|
|
||||||
// Consistency checks
|
// Consistency checks
|
||||||
auto header = pindexNew->GetBlockHeader();
|
auto header = pindexNew->GetBlockHeader();
|
||||||
if (header.GetHash() != pindexNew->GetBlockHash())
|
if (header.GetHash() != pindexNew->GetBlockHash())
|
||||||
|
|||||||
Reference in New Issue
Block a user