Fulcrum/Controller.cpp
Calin Culianu c0ea7f75a0
Refactored things, added "Controller" class
Controller will manage BitcoinD and perhaps synching to bitcoind. It can
"see" all the servers as well as bitcoind.

Also refactored things a little bit and added some more startup sanity
checks.
2019-11-18 00:21:34 +02:00

32 lines
885 B
C++

#include "Controller.h"
Controller::Controller(const std::shared_ptr<Options> &o, QObject *parent)
: Mgr(parent), options(o)
{
}
Controller::~Controller() {}
auto Controller::stats() const -> Stats
{
auto st = srvmgr->statsSafe();
Util::updateMap(st, bitcoindmgr->statsSafe());
return st;
}
void Controller::startup()
{
bitcoindmgr = std::make_unique<BitcoinDMgr>(options->bitcoind.first, options->bitcoind.second, options->rpcuser, options->rpcpassword);
bitcoindmgr->startup(); // may throw
srvmgr = std::make_unique<SrvMgr>(options->interfaces, this);
srvmgr->startup(); // may throw Exception, waits for servers to bind
}
void Controller::cleanup()
{
if (srvmgr) { Log("Stopping SrvMgr ... "); srvmgr->cleanup(); srvmgr.reset(); }
if (bitcoindmgr) { Log("Stopping BitcoinDMgr ... "); bitcoindmgr->cleanup(); bitcoindmgr.reset(); }
}