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

Function FindUndoPos

src/main.cpp:4246–4274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4244}
4245
4246bool FindUndoPos(CValidationState& state, int nFile, CDiskBlockPos& pos, unsigned int nAddSize)
4247{
4248 pos.nFile = nFile;
4249
4250 LOCK(cs_LastBlockFile);
4251
4252 unsigned int nNewSize;
4253 pos.nPos = vinfoBlockFile[nFile].nUndoSize;
4254 nNewSize = vinfoBlockFile[nFile].nUndoSize += nAddSize;
4255 setDirtyFileInfo.insert(nFile);
4256
4257 unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE;
4258 unsigned int nNewChunks = (nNewSize + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE;
4259 if (nNewChunks > nOldChunks) {
4260 if (fPruneMode)
4261 fCheckForPruning = true;
4262 if (CheckDiskSpace(nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos)) {
4263 FILE* file = OpenUndoFile(pos);
4264 if (file) {
4265 LogPrintf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
4266 AllocateFileRange(file, pos.nPos, nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos);
4267 fclose(file);
4268 }
4269 } else
4270 return state.Error("out of disk space");
4271 }
4272
4273 return true;
4274}
4275
4276bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW) {
4277 // Get prev block index

Callers 1

ConnectBlockFunction · 0.85

Calls 5

CheckDiskSpaceFunction · 0.85
OpenUndoFileFunction · 0.85
AllocateFileRangeFunction · 0.85
ErrorMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected