diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f66b1b204..f280cfc72 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -1410,16 +1410,18 @@ UniValue getchaintips(const UniValue& params, bool fHelp) + HelpExampleRpc("getchaintips", "") ); + if ( mapBlockIndex == 0 ) + throw runtime_error("mapBlockIndex is NULL\n"); LOCK(cs_main); /* Build up a list of chain tips. We start with the list of all known blocks, and successively remove blocks that appear as pprev of another block. */ + std::set setTips; BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) { - if ( item != 0 ) - setTips.insert(item.second); + setTips.insert(item.second); } BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) {