From e3d333f8b266284349917668b6cac6a3942d5f1e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 22 Mar 2015 03:15:20 +0300 Subject: [PATCH] converted from "fix possible block db breakage during re-index" https://github.com/bitcoin/bitcoin/commit/bb6acff07982dda68b5c2ac81c99dbd7255bb9cc --- src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4358f2a0d2..130ad515ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2742,8 +2742,11 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd pos.nPos = infoLastBlockFile.nSize; } - infoLastBlockFile.nSize += nAddSize; infoLastBlockFile.AddBlock(nHeight, nTime); + if (fKnown) + infoLastBlockFile.nSize = std::max(pos.nPos + nAddSize, infoLastBlockFile.nSize); + else + infoLastBlockFile.nSize += nAddSize; if (!fKnown) { unsigned int nOldChunks = (pos.nPos + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE;