MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FindUndoPos

Function FindUndoPos

src/validation.cpp:3245–3274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3243}
3244
3245static bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize)
3246{
3247 pos.nFile = nFile;
3248
3249 LOCK(cs_LastBlockFile);
3250
3251 unsigned int nNewSize;
3252 pos.nPos = vinfoBlockFile[nFile].nUndoSize;
3253 nNewSize = vinfoBlockFile[nFile].nUndoSize += nAddSize;
3254 setDirtyFileInfo.insert(nFile);
3255
3256 unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE;
3257 unsigned int nNewChunks = (nNewSize + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE;
3258 if (nNewChunks > nOldChunks) {
3259 if (fPruneMode)
3260 fCheckForPruning = true;
3261 if (CheckDiskSpace(nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos, true)) {
3262 FILE *file = OpenUndoFile(pos);
3263 if (file) {
3264 LogPrintf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
3265 AllocateFileRange(file, pos.nPos, nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos);
3266 fclose(file);
3267 }
3268 }
3269 else
3270 return state.Error("out of disk space");
3271 }
3272
3273 return true;
3274}
3275
3276static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true)
3277{

Callers 1

WriteUndoDataForBlockFunction · 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