Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | using NodeSet = boost::multi_index_container< | ||||
boost::multi_index::composite_key< | boost::multi_index::composite_key< | ||||
Node, | Node, | ||||
boost::multi_index::member<Node, PeerId, &Node::peerid>, | boost::multi_index::member<Node, PeerId, &Node::peerid>, | ||||
boost::multi_index::member<Node, TimePoint, | boost::multi_index::member<Node, TimePoint, | ||||
&Node::nextRequestTime>>>>>; | &Node::nextRequestTime>>>>>; | ||||
NodeSet nodes; | NodeSet nodes; | ||||
/** Pool of proofs using orphan UTXOs as stake */ | |||||
std::map<ProofId, Proof> orphanProofs; | |||||
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: | ||||
/** | /** | ||||
* Node API. | * Node API. | ||||
*/ | */ | ||||
bool addNode(NodeId nodeid, const Proof &proof, | bool addNode(NodeId nodeid, const Proof &proof, | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | public: | ||||
// Accssors. | // Accssors. | ||||
uint64_t getSlotCount() const { return slotCount; } | uint64_t getSlotCount() const { return slotCount; } | ||||
uint64_t getFragmentation() const { return fragmentation; } | uint64_t getFragmentation() const { return fragmentation; } | ||||
std::vector<Peer> getPeers() const; | std::vector<Peer> getPeers() const; | ||||
std::vector<NodeId> getNodeIdsForPeer(PeerId peerId) const; | std::vector<NodeId> getNodeIdsForPeer(PeerId peerId) const; | ||||
const Proof *getProof(const ProofId proofId) const; | |||||
bool addProof(Proof &&proof); | |||||
private: | private: | ||||
PeerSet::iterator fetchOrCreatePeer(const Proof &proof); | PeerSet::iterator fetchOrCreatePeer(const Proof &proof); | ||||
PeerSet::iterator fetchOrCreatePeer(const Proof &proof, | |||||
ProofValidationState &state); | |||||
bool addNodeToPeer(const PeerSet::iterator &it); | bool addNodeToPeer(const PeerSet::iterator &it); | ||||
bool removeNodeFromPeer(const PeerSet::iterator &it, uint32_t count = 1); | bool removeNodeFromPeer(const PeerSet::iterator &it, uint32_t count = 1); | ||||
}; | }; | ||||
/** | /** | ||||
* This is an internal method that is exposed for testing purposes. | * This is an internal method that is exposed for testing purposes. | ||||
*/ | */ | ||||
PeerId selectPeerImpl(const std::vector<Slot> &slots, const uint64_t slot, | PeerId selectPeerImpl(const std::vector<Slot> &slots, const uint64_t slot, | ||||
const uint64_t max); | const uint64_t max); | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PEERMANAGER_H | #endif // BITCOIN_AVALANCHE_PEERMANAGER_H |