Changeset View
Changeset View
Standalone View
Standalone View
src/index/base.cpp
// Copyright (c) 2017-2018 The Bitcoin Core developers | // Copyright (c) 2017-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | |||||
#include <config.h> | #include <config.h> | ||||
#include <index/base.h> | #include <index/base.h> | ||||
#include <init.h> | #include <init.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util.h> | #include <util.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <warnings.h> | #include <warnings.h> | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | static const CBlockIndex *NextSyncBlock(const CBlockIndex *pindex_prev) { | ||||
} | } | ||||
return chainActive.Next(chainActive.FindFork(pindex_prev)); | return chainActive.Next(chainActive.FindFork(pindex_prev)); | ||||
} | } | ||||
void BaseIndex::ThreadSync() { | void BaseIndex::ThreadSync() { | ||||
const CBlockIndex *pindex = m_best_block_index.load(); | const CBlockIndex *pindex = m_best_block_index.load(); | ||||
if (!m_synced) { | if (!m_synced) { | ||||
auto &config = GetConfig(); | auto &consensus_params = GetConfig().GetChainParams().GetConsensus(); | ||||
int64_t last_log_time = 0; | int64_t last_log_time = 0; | ||||
int64_t last_locator_write_time = 0; | int64_t last_locator_write_time = 0; | ||||
while (true) { | while (true) { | ||||
if (m_interrupt) { | if (m_interrupt) { | ||||
WriteBestBlock(pindex); | WriteBestBlock(pindex); | ||||
return; | return; | ||||
} | } | ||||
Show All 19 Lines | if (!m_synced) { | ||||
if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < | if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < | ||||
current_time) { | current_time) { | ||||
WriteBestBlock(pindex); | WriteBestBlock(pindex); | ||||
last_locator_write_time = current_time; | last_locator_write_time = current_time; | ||||
} | } | ||||
CBlock block; | CBlock block; | ||||
if (!ReadBlockFromDisk(block, pindex, config)) { | if (!ReadBlockFromDisk(block, pindex, consensus_params)) { | ||||
FatalError("%s: Failed to read block %s from disk", __func__, | FatalError("%s: Failed to read block %s from disk", __func__, | ||||
pindex->GetBlockHash().ToString()); | pindex->GetBlockHash().ToString()); | ||||
return; | return; | ||||
} | } | ||||
if (!WriteBlock(block, pindex)) { | if (!WriteBlock(block, pindex)) { | ||||
FatalError("%s: Failed to write block %s to index database", | FatalError("%s: Failed to write block %s to index database", | ||||
__func__, pindex->GetBlockHash().ToString()); | __func__, pindex->GetBlockHash().ToString()); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |