MCPcopy Create free account
hub / github.com/LUX-Core/lux / WriteBlockIndex

Method WriteBlockIndex

src/txdb.cpp:115–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115bool CBlockTreeDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
116{
117
118 auto const &hash = blockindex.GetBlockHash();
119 if (blockindex.IsProofOfStake()) {
120 if (blockindex.hashProofOfStake == 0) {
121 uint256 hashProofOfStake;
122 if (stake->GetProof(hash, hashProofOfStake)) {
123 CDiskBlockIndex blockindexFixed(&blockindex);
124 blockindexFixed.hashProofOfStake = hashProofOfStake;
125 return Write(make_pair(DB_BLOCK_INDEX, hash), blockindexFixed);
126 } else {
127# if 0
128 LogPrint("debug", "%s: zero stake block %s", __func__, hash.GetHex());
129# else
130 return error("%s: zero stake (block %s)", __func__, hash.GetHex());
131# endif
132 }
133 }
134# if 0
135 } else if (!CheckProofOfWork(hash, blockindex.nBits, Params().GetConsensus())) {
136 LogPrint("debug", "%s: bad work block %d %d %s", __func__, blockindex.nBits, blockindex.nHeight, hash.GetHex()); //return error("%s: invalid proof of work: %d %d %s", __func__, blockindex.nBits, blockindex.nHeight, hash.GetHex());
137# endif
138 }
139 return Write(make_pair(DB_BLOCK_INDEX, hash), blockindex);
140}
141
142bool CBlockTreeDB::WriteBlockFileInfo(int nFile, const CBlockFileInfo& info)
143{

Callers 1

ConnectBlockFunction · 0.80

Calls 8

LogPrintFunction · 0.85
errorFunction · 0.85
CheckProofOfWorkFunction · 0.85
GetProofMethod · 0.80
ParamsClass · 0.70
GetBlockHashMethod · 0.45
IsProofOfStakeMethod · 0.45
GetHexMethod · 0.45

Tested by

no test coverage detected