| 3251 | } |
| 3252 | |
| 3253 | bool 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 | |
| 3284 | bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW) |
| 3285 | { |
no test coverage detected