blob: 48e527c5751aba7d17234a698322928dcfa4ef01 (
plain)
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
|
#pragma once
#include "DirectConnection.hpp"
#include "IpAddress.hpp"
#include "PubsubKey.hpp"
#include <vector>
namespace sibs
{
class BootstrapException : public std::runtime_error
{
public:
BootstrapException(const std::string &errMsg) : std::runtime_error(errMsg) {}
};
class BootstrapNode
{
DISABLE_COPY(BootstrapNode)
public:
// Throws SocketCreateException or BootstrapException on error
BootstrapNode(const Ipv4 &address);
~BootstrapNode();
private:
void acceptConnections();
void peerSubscribe(std::shared_ptr<DirectConnectionPeer> peer, const void *data, const usize size);
private:
DirectConnections connections;
int socket;
std::thread acceptConnectionsThread;
PubsubKeyMap<std::vector<std::shared_ptr<DirectConnectionPeer>>> subscribedPeers;
};
}
|