Undo for tmp files

This commit is contained in:
jl777
2019-01-24 02:29:23 -11:00
parent 2367a5cc0b
commit 420158a628

View File

@@ -4637,18 +4637,18 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u
bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize) bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize)
{ {
std::vector<CBlockFileInfo> *ptr; int *lastfilep;
LOCK(cs_LastBlockFile);
if ( nFile >= TMPFILE_START ) if ( nFile >= TMPFILE_START )
{ {
fprintf(stderr,"FindUndoPos unexpected tmpfile %d\n",nFile); nFile %= TMPFILE_START;
return(false); ptr = &tmpBlockFiles;
} } else ptr = &vinfoBlockFile;
pos.nFile = nFile; pos.nFile = nFile;
LOCK(cs_LastBlockFile);
unsigned int nNewSize; unsigned int nNewSize;
pos.nPos = vinfoBlockFile[nFile].nUndoSize; pos.nPos = (*ptr)[nFile].nUndoSize;
nNewSize = vinfoBlockFile[nFile].nUndoSize += nAddSize; nNewSize = (*ptr)[nFile].nUndoSize += nAddSize;
setDirtyFileInfo.insert(nFile); setDirtyFileInfo.insert(nFile);
unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE; unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE;