mirror of
https://github.com/cculianu/Fulcrum.git
synced 2026-08-18 13:09:12 +02:00
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.
32 lines
885 B
C++
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(); }
|
|
}
|