aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-02-22 09:00:13 -0800
committerGavin Andresen <gavinandresen@gmail.com>2013-02-22 09:00:13 -0800
commitb8f4e42e1bd9f80690d61dc2ab86edb14b2ecb40 (patch)
tree23f8ccc7000a4fe55a4d3eaed644705fe2a34a01 /src/main.cpp
parent9dca7190f91189f5c0b8a7974fcc522e47d60e50 (diff)
parent1eb578796c98f457546059b66eb98fd0efc8e690 (diff)
Merge pull request #2229 from sipa/prealloc
Native versions for AllocateFileRange()
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3151a806dc..9edd9a2990 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1533,7 +1533,7 @@ bool CBlock::DisconnectBlock(CValidationState &state, CBlockIndex *pindex, CCoin
}
}
-void static FlushBlockFile()
+void static FlushBlockFile(bool fFinalize = false)
{
LOCK(cs_LastBlockFile);
@@ -1541,12 +1541,16 @@ void static FlushBlockFile()
FILE *fileOld = OpenBlockFile(posOld);
if (fileOld) {
+ if (fFinalize)
+ TruncateFile(fileOld, infoLastBlockFile.nSize);
FileCommit(fileOld);
fclose(fileOld);
}
fileOld = OpenUndoFile(posOld);
if (fileOld) {
+ if (fFinalize)
+ TruncateFile(fileOld, infoLastBlockFile.nUndoSize);
FileCommit(fileOld);
fclose(fileOld);
}
@@ -1965,7 +1969,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
} else {
while (infoLastBlockFile.nSize + nAddSize >= MAX_BLOCKFILE_SIZE) {
printf("Leaving block file %i: %s\n", nLastBlockFile, infoLastBlockFile.ToString().c_str());
- FlushBlockFile();
+ FlushBlockFile(true);
nLastBlockFile++;
infoLastBlockFile.SetNull();
pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile); // check whether data for the new file somehow already exist; can fail just fine