| 4244 | } |
| 4245 | |
| 4246 | bool 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 | |
| 4276 | bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW) { |
| 4277 | // Get prev block index |
no test coverage detected