Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/node.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
namespace interfaces { | namespace interfaces { | ||||
class Wallet; | class Wallet; | ||||
namespace { | namespace { | ||||
class NodeImpl : public Node { | class NodeImpl : public Node { | ||||
public: | public: | ||||
NodeImpl() { m_interfaces.chain = MakeChain(); } | NodeImpl() { m_context.chain = MakeChain(); } | ||||
void initError(const std::string &message) override { | void initError(const std::string &message) override { | ||||
InitError(message); | InitError(message); | ||||
} | } | ||||
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 { | ||||
Show All 24 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); | m_context); | ||||
} | } | ||||
void appShutdown() override { | void appShutdown() override { | ||||
Interrupt(); | Interrupt(); | ||||
Shutdown(m_interfaces); | Shutdown(m_context); | ||||
} | } | ||||
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 207 Lines • ▼ Show 20 Lines | public: | ||||
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; | NodeContext m_context; | ||||
}; | }; | ||||
} // 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 |