mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Add forkpoint
to getchaintips
(#2039)
This commit is contained in:
parent
f8e5c5d56e
commit
138441eb82
@ -54,8 +54,11 @@ class GetChainTipsTest (BitcoinTestFramework):
|
||||
|
||||
assert_equal (tips[1]['branchlen'], 10)
|
||||
assert_equal (tips[1]['status'], 'valid-fork')
|
||||
# We already checked that the long tip is the active one,
|
||||
# update data to verify that the short tip matches the expected one.
|
||||
tips[1]['branchlen'] = 0
|
||||
tips[1]['status'] = 'active'
|
||||
tips[1]['forkpoint'] = tips[1]['hash']
|
||||
assert_equal (tips[1], shortTip)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1320,6 +1320,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
|
||||
" \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n"
|
||||
" \"branchlen\": 0 (numeric) zero for main chain\n"
|
||||
" \"forkpoint\": \"xxxx\", (string) same as \"hash\" for the main chain\n"
|
||||
" \"status\": \"active\" (string) \"active\" for the main chain\n"
|
||||
" },\n"
|
||||
" {\n"
|
||||
@ -1328,6 +1329,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||
" \"difficulty\" : x.xxx,\n"
|
||||
" \"chainwork\" : \"0000...1f3\"\n"
|
||||
" \"branchlen\": 1 (numeric) length of branch connecting the tip to the main chain\n"
|
||||
" \"forkpoint\": \"xxxx\", (string) block hash of the last common block between this tip and the main chain\n"
|
||||
" \"status\": \"xxxx\" (string) status of the chain (active, valid-fork, valid-headers, headers-only, invalid)\n"
|
||||
" }\n"
|
||||
"]\n"
|
||||
@ -1386,7 +1388,8 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||
UniValue res(UniValue::VARR);
|
||||
BOOST_FOREACH(const CBlockIndex* block, setTips)
|
||||
{
|
||||
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
|
||||
const CBlockIndex* pindexFork = chainActive.FindFork(block);
|
||||
const int branchLen = block->nHeight - pindexFork->nHeight;
|
||||
if(branchLen < nBranchMin) continue;
|
||||
|
||||
if(nCountMax-- < 1) break;
|
||||
@ -1397,6 +1400,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||
obj.push_back(Pair("difficulty", GetDifficulty(block)));
|
||||
obj.push_back(Pair("chainwork", block->nChainWork.GetHex()));
|
||||
obj.push_back(Pair("branchlen", branchLen));
|
||||
obj.push_back(Pair("forkpoint", pindexFork->phashBlock->GetHex()));
|
||||
|
||||
std::string status;
|
||||
if (chainActive.Contains(block)) {
|
||||
|
Loading…
Reference in New Issue
Block a user