MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / InsertBlockIndex

Function InsertBlockIndex

src/persistence/blockdb.cpp:84–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84CBlockIndex *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 ****************************/

Callers 1

LoadBlockIndexesMethod · 0.85

Calls 4

IsNullMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected