Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/node.cpp
// 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. | ||||
#include <interfaces/node.h> | #include <interfaces/node.h> | ||||
#include <addrdb.h> | #include <addrdb.h> | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <banman.h> | #include <banman.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <init.h> | #include <init.h> | ||||
#include <interfaces/chain.h> | |||||
#include <interfaces/handler.h> | #include <interfaces/handler.h> | ||||
#include <interfaces/wallet.h> | #include <interfaces/wallet.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <net_processing.h> | #include <net_processing.h> | ||||
#include <netaddress.h> | #include <netaddress.h> | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <policy/fees.h> | #include <policy/fees.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
Show All 26 Lines | |||||
#include <atomic> | #include <atomic> | ||||
class HTTPRPCRequestProcessor; | class HTTPRPCRequestProcessor; | ||||
namespace interfaces { | namespace interfaces { | ||||
namespace { | namespace { | ||||
class NodeImpl : public Node { | class NodeImpl : public Node { | ||||
public: | |||||
NodeImpl() { m_interfaces.chain = MakeChain(); } | |||||
bool parseParameters(int argc, const char *const argv[], | bool parseParameters(int argc, const char *const argv[], | ||||
std::string &error) override { | std::string &error) override { | ||||
return gArgs.ParseParameters(argc, argv, error); | return gArgs.ParseParameters(argc, argv, error); | ||||
} | } | ||||
bool readConfigFiles(std::string &error) override { | bool readConfigFiles(std::string &error) override { | ||||
return gArgs.ReadConfigFiles(error); | return gArgs.ReadConfigFiles(error); | ||||
} | } | ||||
bool softSetArg(const std::string &arg, | bool softSetArg(const std::string &arg, | ||||
Show All 14 Lines | public: | ||||
} | } | ||||
bool baseInitialize(Config &config) override { | bool baseInitialize(Config &config) override { | ||||
return AppInitBasicSetup() && AppInitParameterInteraction(config) && | return AppInitBasicSetup() && AppInitParameterInteraction(config) && | ||||
AppInitSanityChecks() && AppInitLockDataDirectory(); | AppInitSanityChecks() && AppInitLockDataDirectory(); | ||||
} | } | ||||
bool | bool | ||||
appInitMain(Config &config, RPCServer &rpcServer, | appInitMain(Config &config, RPCServer &rpcServer, | ||||
HTTPRPCRequestProcessor &httpRPCRequestProcessor) override { | HTTPRPCRequestProcessor &httpRPCRequestProcessor) override { | ||||
return AppInitMain(config, rpcServer, httpRPCRequestProcessor); | return AppInitMain(config, rpcServer, httpRPCRequestProcessor, | ||||
m_interfaces); | |||||
} | } | ||||
void appShutdown() override { | void appShutdown() override { | ||||
Interrupt(); | Interrupt(); | ||||
Shutdown(); | Shutdown(m_interfaces); | ||||
} | } | ||||
void startShutdown() override { StartShutdown(); } | void startShutdown() override { StartShutdown(); } | ||||
bool shutdownRequested() override { return ShutdownRequested(); } | bool shutdownRequested() override { return ShutdownRequested(); } | ||||
void mapPort(bool use_upnp) override { | void mapPort(bool use_upnp) override { | ||||
if (use_upnp) { | if (use_upnp) { | ||||
StartMapPort(); | StartMapPort(); | ||||
} else { | } else { | ||||
InterruptMapPort(); | InterruptMapPort(); | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | #endif | ||||
std::unique_ptr<Handler> | std::unique_ptr<Handler> | ||||
handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { | handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { | ||||
return MakeHandler(::uiInterface.NotifyHeaderTip.connect( | return MakeHandler(::uiInterface.NotifyHeaderTip.connect( | ||||
[fn](bool initial_download, const CBlockIndex *block) { | [fn](bool initial_download, const CBlockIndex *block) { | ||||
fn(initial_download, block->nHeight, block->GetBlockTime(), | fn(initial_download, block->nHeight, block->GetBlockTime(), | ||||
GuessVerificationProgress(Params().TxData(), block)); | GuessVerificationProgress(Params().TxData(), block)); | ||||
})); | })); | ||||
} | } | ||||
InitInterfaces m_interfaces; | |||||
}; | }; | ||||
} // namespace | } // namespace | ||||
std::unique_ptr<Node> MakeNode() { | std::unique_ptr<Node> MakeNode() { | ||||
return std::make_unique<NodeImpl>(); | return std::make_unique<NodeImpl>(); | ||||
} | } | ||||
} // namespace interfaces | } // namespace interfaces |