aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2014-10-29 17:01:01 -0700
committerMatt Corallo <git@bluematt.me>2014-10-29 17:01:01 -0700
commit4ead850fe54ae0bdfb4b3724cbefb3425a16b74a (patch)
tree43b76189ea7ade86ba8bbd4b164f144aa27898fe /src/main.cpp
parent723c7526368badda15df8ac1ffc047a0ab2e384a (diff)
Fix for crash during block download
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 008a059103..0506a7f598 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1739,9 +1739,9 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
}
// Update the on-disk chain state.
-bool static WriteChainState(CValidationState &state) {
+bool static WriteChainState(CValidationState &state, bool forceWrite=false) {
static int64_t nLastWrite = 0;
- if (pcoinsTip->GetCacheSize() > nCoinCacheSize || (!IsInitialBlockDownload() && GetTimeMicros() > nLastWrite + 600*1000000)) {
+ if (forceWrite || pcoinsTip->GetCacheSize() > nCoinCacheSize || (!IsInitialBlockDownload() && GetTimeMicros() > nLastWrite + 600*1000000)) {
// Typical CCoins structures on disk are around 100 bytes in size.
// Pushing a new one to the database can cause it to be written
// twice (once in the log, and once in the tables). This is already
@@ -2999,6 +2999,8 @@ bool InitBlockIndex() {
return error("LoadBlockIndex() : genesis block not accepted");
if (!ActivateBestChain(state, &block))
return error("LoadBlockIndex() : genesis block cannot be activated");
+ // Force a chainstate write so that when we VerifyDB in a moment, it doesnt check stale data
+ return WriteChainState(state, true);
} catch(std::runtime_error &e) {
return error("LoadBlockIndex() : failed to initialize block database: %s", e.what());
}