2021-07-14 05:03:25 -04:00
|
|
|
// Copyright (c) 2014-2021 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_QT_INITEXECUTOR_H
|
|
|
|
#define BITCOIN_QT_INITEXECUTOR_H
|
|
|
|
|
|
|
|
#include <interfaces/node.h>
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QString;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
/** Class encapsulating Bitcoin Core startup and shutdown.
|
|
|
|
* Allows running startup and shutdown in a different thread from the UI thread.
|
|
|
|
*/
|
2021-07-14 05:21:54 -04:00
|
|
|
class InitExecutor : public QObject
|
2021-07-14 05:03:25 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit InitExecutor(interfaces::Node& node);
|
|
|
|
~InitExecutor();
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void initialize();
|
|
|
|
void shutdown();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
|
|
|
|
void shutdownResult();
|
2021-07-14 05:21:54 -04:00
|
|
|
void runawayException(const QString& message);
|
2021-07-14 05:03:25 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Pass fatal exception message to UI thread
|
2021-07-14 05:21:54 -04:00
|
|
|
void handleRunawayException(const std::exception* e);
|
2021-07-14 05:03:25 -04:00
|
|
|
|
|
|
|
interfaces::Node& m_node;
|
2021-09-26 11:11:46 -03:00
|
|
|
QObject m_context;
|
2021-07-14 05:03:25 -04:00
|
|
|
QThread m_thread;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITCOIN_QT_INITEXECUTOR_H
|