forked from cculianu/Fulcrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSrvMgr.h
59 lines (51 loc) · 1.85 KB
/
SrvMgr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Fulcrum - A fast & nimble SPV Server for Bitcoin Cash
// Copyright (C) 2019-2020 Calin A. Culianu <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program (see LICENSE.txt). If not, see
// <https://www.gnu.org/licenses/>.
//
#pragma once
#include "Mgr.h"
#include "Options.h"
#include <list>
#include <memory>
class BitcoinDMgr;
class Server;
class Storage;
class SrvMgr : public Mgr
{
Q_OBJECT
public:
explicit SrvMgr(const std::shared_ptr<Options> & options,
const std::shared_ptr<Storage> & storage,
const std::shared_ptr<BitcoinDMgr> & bitcoindmgr,
QObject *parent = nullptr);
~SrvMgr() override;
void startup() override; // may throw on error
void cleanup() override;
int nServers() const { return int(servers.size()); }
signals:
/// Notifies all blockchain.headers.subscribe'd clients for the entire server about a new header.
/// (normally connected to the Controller::newHeader signal).
void newHeader(unsigned height, const QByteArray &header);
protected:
Stats stats() const override;
private:
void startServers();
const std::shared_ptr<Options> options;
std::shared_ptr<Storage> storage;
std::shared_ptr<BitcoinDMgr> bitcoindmgr;
std::list<std::unique_ptr<Server>> servers;
};