forked from stellar/stellar-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomPeerSource.h
35 lines (26 loc) · 872 Bytes
/
RandomPeerSource.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
#pragma once
// Copyright 2019 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "overlay/PeerManager.h"
#include <functional>
#include <vector>
namespace stellar
{
enum class PeerType;
class PeerManager;
struct PeerQuery;
class RandomPeerSource
{
public:
static PeerQuery maxFailures(int maxFailures, bool outbound);
static PeerQuery nextAttemptCutoff(PeerType peerType);
explicit RandomPeerSource(PeerManager& peerManager, PeerQuery peerQuery);
std::vector<PeerBareAddress>
getRandomPeers(int size, std::function<bool(PeerBareAddress const&)> pred);
private:
PeerManager& mPeerManager;
PeerQuery const mPeerQuery;
std::vector<PeerBareAddress> mPeerCache;
};
}