aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2022-10-11 23:35:28 -0400
committerRyan Ofsky <ryan@ofsky.org>2022-11-29 08:12:24 -0400
commit82e272a109281f750909d1feade784c778d8b592 (patch)
treede882a0536469dc9990644d2c9079a33fd7c778a /src/interfaces
parenta035b6a0c418d0b720707df69559028bd662fa70 (diff)
downloadbitcoin-82e272a109281f750909d1feade784c778d8b592.tar.xz
refactor: Move src/interfaces/*.cpp files to libbitcoin_common.a
These belong in libbitcoin_common.a, not libbitcoin_util.a, because they aren't general-purpose utilities, they just contain common code that is used by both the node and the wallet. Another reason to reason to not include these in libbitcoin_util.a is to prevent them from being used by the kernel library.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/echo.cpp18
-rw-r--r--src/interfaces/handler.cpp45
-rw-r--r--src/interfaces/init.cpp17
-rw-r--r--src/interfaces/init.h19
4 files changed, 10 insertions, 89 deletions
diff --git a/src/interfaces/echo.cpp b/src/interfaces/echo.cpp
deleted file mode 100644
index 9bbb42217b..0000000000
--- a/src/interfaces/echo.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 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.
-
-#include <interfaces/echo.h>
-
-#include <memory>
-
-namespace interfaces {
-namespace {
-class EchoImpl : public Echo
-{
-public:
- std::string echo(const std::string& echo) override { return echo; }
-};
-} // namespace
-std::unique_ptr<Echo> MakeEcho() { return std::make_unique<EchoImpl>(); }
-} // namespace interfaces
diff --git a/src/interfaces/handler.cpp b/src/interfaces/handler.cpp
deleted file mode 100644
index adb7031cbc..0000000000
--- a/src/interfaces/handler.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2018-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.
-
-#include <interfaces/handler.h>
-
-
-#include <boost/signals2/connection.hpp>
-#include <utility>
-
-namespace interfaces {
-namespace {
-
-class HandlerImpl : public Handler
-{
-public:
- explicit HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
-
- void disconnect() override { m_connection.disconnect(); }
-
- boost::signals2::scoped_connection m_connection;
-};
-
-class CleanupHandler : public Handler
-{
-public:
- explicit CleanupHandler(std::function<void()> cleanup) : m_cleanup(std::move(cleanup)) {}
- ~CleanupHandler() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
- void disconnect() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
- std::function<void()> m_cleanup;
-};
-
-} // namespace
-
-std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
-{
- return std::make_unique<HandlerImpl>(std::move(connection));
-}
-
-std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup)
-{
- return std::make_unique<CleanupHandler>(std::move(cleanup));
-}
-
-} // namespace interfaces
diff --git a/src/interfaces/init.cpp b/src/interfaces/init.cpp
deleted file mode 100644
index f0f8aa5fed..0000000000
--- a/src/interfaces/init.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 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.
-
-#include <interfaces/chain.h>
-#include <interfaces/echo.h>
-#include <interfaces/init.h>
-#include <interfaces/node.h>
-#include <interfaces/wallet.h>
-
-namespace interfaces {
-std::unique_ptr<Node> Init::makeNode() { return {}; }
-std::unique_ptr<Chain> Init::makeChain() { return {}; }
-std::unique_ptr<WalletLoader> Init::makeWalletLoader(Chain& chain) { return {}; }
-std::unique_ptr<Echo> Init::makeEcho() { return {}; }
-Ipc* Init::ipc() { return nullptr; }
-} // namespace interfaces
diff --git a/src/interfaces/init.h b/src/interfaces/init.h
index 2153076366..5b8f61640e 100644
--- a/src/interfaces/init.h
+++ b/src/interfaces/init.h
@@ -5,6 +5,11 @@
#ifndef BITCOIN_INTERFACES_INIT_H
#define BITCOIN_INTERFACES_INIT_H
+#include <interfaces/chain.h>
+#include <interfaces/echo.h>
+#include <interfaces/node.h>
+#include <interfaces/wallet.h>
+
#include <memory>
namespace node {
@@ -12,11 +17,7 @@ struct NodeContext;
} // namespace node
namespace interfaces {
-class Chain;
-class Echo;
class Ipc;
-class Node;
-class WalletLoader;
//! Initial interface created when a process is first started, and used to give
//! and get access to other interfaces (Node, Chain, Wallet, etc).
@@ -29,11 +30,11 @@ class Init
{
public:
virtual ~Init() = default;
- virtual std::unique_ptr<Node> makeNode();
- virtual std::unique_ptr<Chain> makeChain();
- virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain);
- virtual std::unique_ptr<Echo> makeEcho();
- virtual Ipc* ipc();
+ virtual std::unique_ptr<Node> makeNode() { return nullptr; }
+ virtual std::unique_ptr<Chain> makeChain() { return nullptr; }
+ virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain) { return nullptr; }
+ virtual std::unique_ptr<Echo> makeEcho() { return nullptr; }
+ virtual Ipc* ipc() { return nullptr; }
};
//! Return implementation of Init interface for the node process. If the argv