Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
struct Peer { | struct Peer { | ||||
PeerId peerid; | PeerId peerid; | ||||
uint32_t index = -1; | uint32_t index = -1; | ||||
uint32_t node_count = 0; | uint32_t node_count = 0; | ||||
ProofRef proof; | ProofRef proof; | ||||
// The network stack uses timestamp in seconds, so we oblige. | // The network stack uses timestamp in seconds, so we oblige. | ||||
std::chrono::seconds registration_time; | |||||
std::chrono::seconds nextPossibleConflictTime; | std::chrono::seconds nextPossibleConflictTime; | ||||
Peer(PeerId peerid_, ProofRef proof_, | Peer(PeerId peerid_, ProofRef proof_, | ||||
std::chrono::seconds nextPossibleConflictTime_) | std::chrono::seconds nextPossibleConflictTime_) | ||||
: peerid(peerid_), proof(std::move(proof_)), | : peerid(peerid_), proof(std::move(proof_)), | ||||
registration_time(GetTime<std::chrono::seconds>()), | |||||
nextPossibleConflictTime(std::move(nextPossibleConflictTime_)) {} | nextPossibleConflictTime(std::move(nextPossibleConflictTime_)) {} | ||||
const ProofId &getProofId() const { return proof->getId(); } | const ProofId &getProofId() const { return proof->getId(); } | ||||
uint32_t getScore() const { return proof->getScore(); } | uint32_t getScore() const { return proof->getScore(); } | ||||
}; | }; | ||||
struct proof_index { | struct proof_index { | ||||
using result_type = ProofId; | using result_type = ProofId; | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | public: | ||||
bool isBoundToPeer(const ProofId &proofid) const; | bool isBoundToPeer(const ProofId &proofid) const; | ||||
bool isOrphan(const ProofId &proofid) const; | bool isOrphan(const ProofId &proofid) const; | ||||
bool isInConflictingPool(const ProofId &proofid) const; | bool isInConflictingPool(const ProofId &proofid) const; | ||||
const ProofRadixTree &getShareableProofsSnapshot() const { | const ProofRadixTree &getShareableProofsSnapshot() const { | ||||
return shareableProofs; | return shareableProofs; | ||||
} | } | ||||
std::optional<std::chrono::seconds> | |||||
getProofRegistrationTime(const ProofId &proofid) const; | |||||
private: | private: | ||||
template <typename ProofContainer> | template <typename ProofContainer> | ||||
void moveToConflictingPool(const ProofContainer &proofs); | void moveToConflictingPool(const ProofContainer &proofs); | ||||
bool addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid); | bool addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid); | ||||
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); | ||||
Show All 12 Lines |