Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 191 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; | ||||
/** | /** | ||||
* Track proof ids to broadcast | * Track proof ids to broadcast | ||||
*/ | */ | ||||
std::unordered_set<ProofId, SaltedProofIdHasher> m_unbroadcast_proofids; | std::unordered_set<ProofId, SaltedProofIdHasher> m_unbroadcast_proofids; | ||||
/** | |||||
* Quorum management. | |||||
*/ | |||||
uint32_t knownPeersScore = 0; | |||||
Fabien: Let's try to align with the getavalancheinfo rpc as much as possible, since the names have… | |||||
uint32_t connectedPeersScore = 0; | |||||
public: | public: | ||||
/** | /** | ||||
* Node API. | * Node API. | ||||
*/ | */ | ||||
bool addNode(NodeId nodeid, const ProofId &proofid); | bool addNode(NodeId nodeid, const ProofId &proofid); | ||||
bool removeNode(NodeId nodeid); | bool removeNode(NodeId nodeid); | ||||
size_t getNodeCount() const { return nodes.size(); } | size_t getNodeCount() const { return nodes.size(); } | ||||
size_t getPendingNodeCount() const { return pendingNodes.size(); } | size_t getPendingNodeCount() const { return pendingNodes.size(); } | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Proof broadcast API. | * Proof broadcast API. | ||||
*/ | */ | ||||
void addUnbroadcastProof(const ProofId &proofid); | void addUnbroadcastProof(const ProofId &proofid); | ||||
void removeUnbroadcastProof(const ProofId &proofid); | void removeUnbroadcastProof(const ProofId &proofid); | ||||
auto getUnbroadcastProofs() const { return m_unbroadcast_proofids; } | auto getUnbroadcastProofs() const { return m_unbroadcast_proofids; } | ||||
/* | |||||
* Quorum management | |||||
*/ | |||||
uint32_t getKnownPeersScore() const { return knownPeersScore; } | |||||
uint32_t getConnectedPeersScore() const { return connectedPeersScore; } | |||||
/**************************************************** | /**************************************************** | ||||
* Functions which are public for testing purposes. * | * Functions which are public for testing purposes. * | ||||
****************************************************/ | ****************************************************/ | ||||
/** | /** | ||||
* Remove an existing peer. | * Remove an existing peer. | ||||
*/ | */ | ||||
bool removePeer(const PeerId peerid); | bool removePeer(const PeerId peerid); | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Let's try to align with the getavalancheinfo rpc as much as possible, since the names have already been discussed there totalPeersScore.