Unify claimtrie tests, add some additional root hash checks #181
2 changed files with 12 additions and 15 deletions
|
@ -82,6 +82,11 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe
|
||||||
result.push_back(Pair("nonce", (uint64_t)block.nNonce));
|
result.push_back(Pair("nonce", (uint64_t)block.nNonce));
|
||||||
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
|
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
|
||||||
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
||||||
|
bool fNegative;
|
||||||
|
bool fOverflow;
|
||||||
|
arith_uint256 target;
|
||||||
|
target.SetCompact(block.nBits, &fNegative, &fOverflow);
|
||||||
|
result.push_back(Pair("target", target.ToString()));
|
||||||
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
|
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
|
||||||
|
|
||||||
if (blockindex->pprev)
|
if (blockindex->pprev)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "ncc.h"
|
#include "ncc.h"
|
||||||
|
#include "rpcserver.h"
|
||||||
|
|
||||||
#include "json/json_spirit_value.h"
|
#include "json/json_spirit_value.h"
|
||||||
|
|
||||||
|
@ -118,15 +119,12 @@ Value gettotalclaimednames(const Array& params, bool fHelp)
|
||||||
" names in the trie\n"
|
" names in the trie\n"
|
||||||
);
|
);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Object ret;
|
|
||||||
if (!pnccTrie)
|
if (!pnccTrie)
|
||||||
{
|
{
|
||||||
ret.push_back(Pair("total names", -1));
|
return -1;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
unsigned int num_names = pnccTrie->getTotalNamesInTrie();
|
unsigned int num_names = pnccTrie->getTotalNamesInTrie();
|
||||||
ret.push_back(Pair("total names", (int)num_names));
|
return int(num_names);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value gettotalclaims(const Array& params, bool fHelp)
|
Value gettotalclaims(const Array& params, bool fHelp)
|
||||||
|
@ -141,15 +139,12 @@ Value gettotalclaims(const Array& params, bool fHelp)
|
||||||
" of active claims\n"
|
" of active claims\n"
|
||||||
);
|
);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Object ret;
|
|
||||||
if (!pnccTrie)
|
if (!pnccTrie)
|
||||||
{
|
{
|
||||||
ret.push_back(Pair("total claims", -1));
|
return -1;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
unsigned int num_claims = pnccTrie->getTotalClaimsInTrie();
|
unsigned int num_claims = pnccTrie->getTotalClaimsInTrie();
|
||||||
ret.push_back(Pair("total claims", (int)num_claims));
|
return int(num_claims);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value gettotalvalueofclaims(const Array& params, bool fHelp)
|
Value gettotalvalueofclaims(const Array& params, bool fHelp)
|
||||||
|
@ -166,17 +161,14 @@ Value gettotalvalueofclaims(const Array& params, bool fHelp)
|
||||||
" claims in the trie\n"
|
" claims in the trie\n"
|
||||||
);
|
);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Object ret;
|
|
||||||
if (!pnccTrie)
|
if (!pnccTrie)
|
||||||
{
|
{
|
||||||
ret.push_back(Pair("total value", -1));
|
return -1;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
bool controlling_only = false;
|
bool controlling_only = false;
|
||||||
if (params.size() == 1)
|
if (params.size() == 1)
|
||||||
controlling_only = params[0].get_bool();
|
controlling_only = params[0].get_bool();
|
||||||
CAmount total_amount = pnccTrie->getTotalValueOfClaimsInTrie(controlling_only);
|
CAmount total_amount = pnccTrie->getTotalValueOfClaimsInTrie(controlling_only);
|
||||||
ret.push_back(Pair("total value", total_amount));
|
return ValueFromAmount(total_amount);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue