| 82 | } |
| 83 | |
| 84 | CBlockIndex *InsertBlockIndex(uint256 hash) { |
| 85 | if (hash.IsNull()) |
| 86 | return nullptr; |
| 87 | |
| 88 | // Return existing |
| 89 | map<uint256, CBlockIndex *>::iterator mi = mapBlockIndex.find(hash); |
| 90 | if (mi != mapBlockIndex.end()) |
| 91 | return (*mi).second; |
| 92 | |
| 93 | // Create new |
| 94 | CBlockIndex *pIndexNew = new CBlockIndex(); |
| 95 | if (!pIndexNew) |
| 96 | throw runtime_error("new CBlockIndex failed"); |
| 97 | mi = mapBlockIndex.insert(make_pair(hash, pIndexNew)).first; |
| 98 | pIndexNew->pBlockHash = &((*mi).first); |
| 99 | |
| 100 | return pIndexNew; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /************************* CBlockDBCache ****************************/ |
no test coverage detected