-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaddrseed.h
39 lines (33 loc) · 976 Bytes
/
addrseed.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
#ifndef __ADDRSET_H__
#define __ADDRSET_H__
#include <bitcoin/protocol.h>
#include <set>
#include <deque>
#include <mutex>
#include <condition_variable>
static std::mutex instanceLock;
class CAddrSeed
{
public:
CAddrSeed(const CAddrSeed &) = delete;
CAddrSeed& operator=(const CAddrSeed &) = delete;
static CAddrSeed &getInstance() {
if (mInstance == nullptr) {
std::lock_guard<std::mutex> lock(instanceLock);
mInstance = new CAddrSeed;
}
return *mInstance;
}
void addNewAddr(const CService &addr);
bool getNewAddrs(std::vector<CService *> &addrs, size_t &size, bool wait=false);
private:
CAddrSeed() = default;
static CAddrSeed *mInstance;
std::condition_variable mCond;
std::mutex mSeedLock;
std::deque<const CService *> mSeedAddr;
std::set<CService> mSeenAddr;
std::vector<const CService *> mTimeoutAddr;
std::vector<const CService *> mRefusedAddr;
};
#endif