Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 69 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; | ||||
std::shared_ptr<Proof> proof; | std::shared_ptr<Proof> proof; | ||||
using Timestamp = std::chrono::time_point<std::chrono::system_clock>; | // The network stack uses timestamp in seconds, so we oblige. | ||||
Timestamp time; | std::chrono::seconds registration_time; | ||||
Peer(PeerId peerid_, std::shared_ptr<Proof> proof_) | Peer(PeerId peerid_, std::shared_ptr<Proof> proof_) | ||||
: peerid(peerid_), proof(std::move(proof_)), | : peerid(peerid_), proof(std::move(proof_)), | ||||
time(std::chrono::seconds(GetTime())) {} | registration_time(GetTime<std::chrono::seconds>()) {} | ||||
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; | ||||
result_type operator()(const Peer &p) const { return p.proof->getId(); } | result_type operator()(const Peer &p) const { return p.proof->getId(); } | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public: | ||||
// Accessors. | // Accessors. | ||||
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; | ||||
std::shared_ptr<Proof> getProof(const ProofId &proofid) const; | std::shared_ptr<Proof> getProof(const ProofId &proofid) const; | ||||
Peer::Timestamp getProofTime(const ProofId &proofid) const; | std::chrono::seconds getProofRegistrationTime(const ProofId &proofid) const; | ||||
bool isOrphan(const ProofId &id) const; | bool isOrphan(const ProofId &id) const; | ||||
std::shared_ptr<Proof> getOrphan(const ProofId &id) const; | std::shared_ptr<Proof> getOrphan(const ProofId &id) const; | ||||
void addUnbroadcastProof(const ProofId &proofid); | void addUnbroadcastProof(const ProofId &proofid); | ||||
void removeUnbroadcastProof(const ProofId &proofid); | void removeUnbroadcastProof(const ProofId &proofid); | ||||
void broadcastProofs(const CConnman &connman); | void broadcastProofs(const CConnman &connman); | ||||
Show All 16 Lines |