Changeset View
Changeset View
Standalone View
Standalone View
src/interface/node.h
// Copyright (c) 2018 The Bitcoin Core developers | // Copyright (c) 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. | ||||
#ifndef BITCOIN_INTERFACE_NODE_H | #ifndef BITCOIN_INTERFACE_NODE_H | ||||
#define BITCOIN_INTERFACE_NODE_H | #define BITCOIN_INTERFACE_NODE_H | ||||
#include <netaddress.h> // For Network | |||||
#include <functional> | #include <functional> | ||||
#include <memory> | #include <memory> | ||||
#include <string> | #include <string> | ||||
class Config; | class Config; | ||||
class HTTPRPCRequestProcessor; | class HTTPRPCRequestProcessor; | ||||
class RPCServer; | class RPCServer; | ||||
class proxyType; | |||||
namespace interface { | namespace interface { | ||||
class Handler; | class Handler; | ||||
//! Top-level interface for a bitcoin node (bitcoind process). | //! Top-level interface for a bitcoin node (bitcoind process). | ||||
class Node { | class Node { | ||||
public: | public: | ||||
virtual ~Node() {} | virtual ~Node() {} | ||||
//! Set command line arguments. | //! Set command line arguments. | ||||
virtual void parseParameters(int argc, const char *const argv[]) = 0; | virtual void parseParameters(int argc, const char *const argv[]) = 0; | ||||
//! Set a command line argument if it doesn't already have a value | |||||
virtual bool softSetArg(const std::string &arg, | |||||
const std::string &value) = 0; | |||||
//! Set a command line boolean argument if it doesn't already have a value | |||||
virtual bool softSetBoolArg(const std::string &arg, bool value) = 0; | |||||
//! Load settings from configuration file. | //! Load settings from configuration file. | ||||
virtual void readConfigFile(const std::string &conf_path) = 0; | virtual void readConfigFile(const std::string &conf_path) = 0; | ||||
//! Choose network parameters. | //! Choose network parameters. | ||||
virtual void selectParams(const std::string &network) = 0; | virtual void selectParams(const std::string &network) = 0; | ||||
//! Init logging. | //! Init logging. | ||||
virtual void initLogging() = 0; | virtual void initLogging() = 0; | ||||
Show All 13 Lines | appInitMain(Config &config, | ||||
HTTPRPCRequestProcessor &httpRPCRequestProcessor) = 0; | HTTPRPCRequestProcessor &httpRPCRequestProcessor) = 0; | ||||
//! Stop node. | //! Stop node. | ||||
virtual void appShutdown() = 0; | virtual void appShutdown() = 0; | ||||
//! Start shutdown. | //! Start shutdown. | ||||
virtual void startShutdown() = 0; | virtual void startShutdown() = 0; | ||||
//! Map port. | |||||
virtual void mapPort(bool use_upnp) = 0; | |||||
//! Get proxy. | |||||
virtual bool getProxy(Network net, proxyType &proxy_info) = 0; | |||||
//! Register handler for init messages. | //! Register handler for init messages. | ||||
using InitMessageFn = std::function<void(const std::string &message)>; | using InitMessageFn = std::function<void(const std::string &message)>; | ||||
virtual std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) = 0; | virtual std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) = 0; | ||||
}; | }; | ||||
//! Return implementation of Node interface. | //! Return implementation of Node interface. | ||||
std::unique_ptr<Node> MakeNode(); | std::unique_ptr<Node> MakeNode(); | ||||
} // namespace interface | } // namespace interface | ||||
#endif // BITCOIN_INTERFACE_NODE_H | #endif // BITCOIN_INTERFACE_NODE_H |