Getchaintips error checks
This commit is contained in:
@@ -1055,7 +1055,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
|
||||
setTips.insert(item.second);
|
||||
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
|
||||
{
|
||||
const CBlockIndex* pprev = item.second->pprev;
|
||||
const CBlockIndex* pprev=0;
|
||||
if ( item.second != 0 )
|
||||
pprev = item.second->pprev;
|
||||
if (pprev)
|
||||
setTips.erase(pprev);
|
||||
}
|
||||
@@ -1064,14 +1066,16 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
|
||||
setTips.insert(chainActive.Tip());
|
||||
|
||||
/* Construct the output array. */
|
||||
UniValue res(UniValue::VARR);
|
||||
UniValue res(UniValue::VARR); CBlockIndex *forked;
|
||||
BOOST_FOREACH(const CBlockIndex* block, setTips)
|
||||
{
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("height", block->nHeight));
|
||||
obj.push_back(Pair("hash", block->phashBlock->GetHex()));
|
||||
|
||||
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
|
||||
forked = chainActive.FindFork(block);
|
||||
if ( forked != 0 )
|
||||
{
|
||||
const int branchLen = block->nHeight - forked->nHeight;
|
||||
obj.push_back(Pair("branchlen", branchLen));
|
||||
|
||||
string status;
|
||||
@@ -1095,7 +1099,7 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
|
||||
status = "unknown";
|
||||
}
|
||||
obj.push_back(Pair("status", status));
|
||||
|
||||
}
|
||||
res.push_back(obj);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user