| 196 | } |
| 197 | |
| 198 | CBlockIndex* BlockManager::InsertBlockIndex(const uint256& hash) |
| 199 | { |
| 200 | AssertLockHeld(cs_main); |
| 201 | |
| 202 | if (hash.IsNull()) { |
| 203 | return nullptr; |
| 204 | } |
| 205 | |
| 206 | // Return existing |
| 207 | BlockMap::iterator mi = m_block_index.find(hash); |
| 208 | if (mi != m_block_index.end()) { |
| 209 | return (*mi).second; |
| 210 | } |
| 211 | |
| 212 | // Create new |
| 213 | CBlockIndex* pindexNew = new CBlockIndex(); |
| 214 | mi = m_block_index.insert(std::make_pair(hash, pindexNew)).first; |
| 215 | pindexNew->phashBlock = &((*mi).first); |
| 216 | |
| 217 | return pindexNew; |
| 218 | } |
| 219 | |
| 220 | bool BlockManager::LoadBlockIndex( |
| 221 | const Consensus::Params& consensus_params, |
no test coverage detected