Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | class PeerManager { | ||||
static constexpr int SELECT_PEER_MAX_RETRY = 3; | static constexpr int SELECT_PEER_MAX_RETRY = 3; | ||||
static constexpr int SELECT_NODE_MAX_RETRY = 3; | static constexpr int SELECT_NODE_MAX_RETRY = 3; | ||||
public: | public: | ||||
/** | /** | ||||
* Peer API. | * Peer API. | ||||
*/ | */ | ||||
PeerId addPeer(uint32_t score) { return addPeer(nextPeerId++, score); } | PeerId addPeer(uint32_t score) { return addPeer(nextPeerId++, score); } | ||||
// Provide the peer associated toa proof. If the peer does not exists, then | |||||
// it is created. | |||||
PeerId getPeer(const Proof &proof); | |||||
bool removePeer(const PeerId peerid); | bool removePeer(const PeerId peerid); | ||||
bool rescorePeer(const PeerId peerid, uint32_t score); | bool rescorePeer(const PeerId peerid, uint32_t score); | ||||
/** | /** | ||||
* Node API. | * Node API. | ||||
*/ | */ | ||||
bool addNodeToPeer(PeerId peerid, NodeId nodeid, CPubKey pubkey); | bool addNode(const Proof &proof, NodeId nodeid, const CPubKey &pubkey); | ||||
bool removeNode(NodeId nodeid); | bool removeNode(NodeId nodeid); | ||||
bool forNode(NodeId nodeid, std::function<bool(const Node &n)> func) const; | bool forNode(NodeId nodeid, std::function<bool(const Node &n)> func) const; | ||||
bool updateNextRequestTime(NodeId nodeid, TimePoint timeout); | bool updateNextRequestTime(NodeId nodeid, TimePoint timeout); | ||||
NodeId selectNode(); | NodeId selectNode(); | ||||
Show All 34 Lines |