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 <chainparams.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <index/base.h> | #include <index/base.h> | ||||
#include <node/blockstorage.h> | #include <node/blockstorage.h> | ||||
#include <node/ui_interface.h> | #include <node/ui_interface.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <util/system.h> | #include <util/thread.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <validation.h> // For CChainState | #include <validation.h> // For CChainState | ||||
#include <warnings.h> | #include <warnings.h> | ||||
#include <functional> | #include <functional> | ||||
constexpr char DB_BEST_BLOCK = 'B'; | constexpr char DB_BEST_BLOCK = 'B'; | ||||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Lines | void BaseIndex::Start(CChainState &active_chainstate) { | ||||
// Need to register this ValidationInterface before running Init(), so that | // Need to register this ValidationInterface before running Init(), so that | ||||
// callbacks are not missed if Init sets m_synced to true. | // callbacks are not missed if Init sets m_synced to true. | ||||
RegisterValidationInterface(this); | RegisterValidationInterface(this); | ||||
if (!Init()) { | if (!Init()) { | ||||
FatalError("%s: %s failed to initialize", __func__, GetName()); | FatalError("%s: %s failed to initialize", __func__, GetName()); | ||||
return; | return; | ||||
} | } | ||||
m_thread_sync = std::thread(&TraceThread<std::function<void()>>, GetName(), | m_thread_sync = | ||||
std::bind(&BaseIndex::ThreadSync, this)); | std::thread(&util::TraceThread, GetName(), [this] { ThreadSync(); }); | ||||
} | } | ||||
void BaseIndex::Stop() { | void BaseIndex::Stop() { | ||||
UnregisterValidationInterface(this); | UnregisterValidationInterface(this); | ||||
if (m_thread_sync.joinable()) { | if (m_thread_sync.joinable()) { | ||||
m_thread_sync.join(); | m_thread_sync.join(); | ||||
} | } | ||||
Show All 10 Lines |