Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2014-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <qt/initexecutor.h>7#include <interfaces/node.h>8#include <util/exception.h>9#include <util/threadnames.h>11#include <exception>13#include <QDebug>14#include <QMetaObject>15#include <QObject>16#include <QString>17#include <QThread>19InitExecutor::InitExecutor(interfaces::Node& node)20: QObject(), m_node(node)21{22m_context.moveToThread(&m_thread);23m_thread.start();24}26InitExecutor::~InitExecutor()27{28qDebug() << __func__ << ": Stopping thread";29m_thread.quit();30m_thread.wait();31qDebug() << __func__ << ": Stopped thread";32}34void InitExecutor::handleRunawayException(const std::exception* e)35{36PrintExceptionContinue(e, "Runaway exception");37Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));38}40void InitExecutor::initialize()41{42QMetaObject::invokeMethod(&m_context, [this] {43try {44util::ThreadRename("qt-init");45qDebug() << "Running initialization in thread";46interfaces::BlockAndHeaderTipInfo tip_info;47bool rv = m_node.appInitMain(&tip_info);48Q_EMIT initializeResult(rv, tip_info);49} catch (const std::exception& e) {50handleRunawayException(&e);51} catch (...) {52handleRunawayException(nullptr);53}54});55}57void InitExecutor::shutdown()58{59QMetaObject::invokeMethod(&m_context, [this] {60try {61qDebug() << "Running Shutdown in thread";62m_node.appShutdown();63qDebug() << "Shutdown finished";64Q_EMIT shutdownResult();65} catch (const std::exception& e) {66handleRunawayException(&e);67} catch (...) {68handleRunawayException(nullptr);69}70});71}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.