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

Function FindUndoPos

src/main.cpp:3253–3282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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