aboutsummaryrefslogtreecommitdiff
path: root/src/qt/initexecutor.h
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-07-14 12:03:25 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-07-14 21:54:32 +0300
commitc82165a55701fe4ff604d7f30163051cd47c2363 (patch)
tree0e2a2059a3b28509b9b54ae76459a940e4fa24d1 /src/qt/initexecutor.h
parentdbcf56b6c6e939923673b3f07bed7bb3632dbeb1 (diff)
downloadbitcoin-c82165a55701fe4ff604d7f30163051cd47c2363.tar.xz
qt, refactor: Move InitExecutor class into its own module
This change makes InitExecutor class re-usable by an alternative GUI, e.g., QML-based one.
Diffstat (limited to 'src/qt/initexecutor.h')
-rw-r--r--src/qt/initexecutor.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/qt/initexecutor.h b/src/qt/initexecutor.h
new file mode 100644
index 0000000000..6c014677ee
--- /dev/null
+++ b/src/qt/initexecutor.h
@@ -0,0 +1,46 @@
+// 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.
+ */
+class InitExecutor: public QObject
+{
+ 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();
+ void runawayException(const QString &message);
+
+private:
+ /// Pass fatal exception message to UI thread
+ void handleRunawayException(const std::exception *e);
+
+ interfaces::Node& m_node;
+ QThread m_thread;
+};
+
+#endif // BITCOIN_QT_INITEXECUTOR_H