Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show All 14 Lines | |||||
#include <boost/multi_index/composite_key.hpp> | #include <boost/multi_index/composite_key.hpp> | ||||
#include <boost/multi_index/hashed_index.hpp> | #include <boost/multi_index/hashed_index.hpp> | ||||
#include <boost/multi_index/member.hpp> | #include <boost/multi_index/member.hpp> | ||||
#include <boost/multi_index/ordered_index.hpp> | #include <boost/multi_index/ordered_index.hpp> | ||||
#include <boost/multi_index_container.hpp> | #include <boost/multi_index_container.hpp> | ||||
#include <chrono> | #include <chrono> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <memory> | |||||
#include <vector> | #include <vector> | ||||
namespace avalanche { | namespace avalanche { | ||||
class Delegation; | class Delegation; | ||||
struct Slot { | struct Slot { | ||||
private: | private: | ||||
Show All 27 Lines | public: | ||||
bool follows(uint64_t slot) const { return getStart() > slot; } | bool follows(uint64_t slot) const { return getStart() > slot; } | ||||
}; | }; | ||||
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; | ||||
Proof proof; | std::shared_ptr<Proof> proof; | ||||
Peer(PeerId peerid_, Proof proof_) | Peer(PeerId peerid_, Proof proof_) | ||||
: peerid(peerid_), proof(std::move(proof_)) {} | : peerid(peerid_), proof(std::make_shared<Proof>(std::move(proof_))) {} | ||||
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(); } | ||||
}; | }; | ||||
struct next_request_time {}; | struct next_request_time {}; | ||||
class PeerManager { | class PeerManager { | ||||
std::vector<Slot> slots; | std::vector<Slot> slots; | ||||
uint64_t slotCount = 0; | uint64_t slotCount = 0; | ||||
uint64_t fragmentation = 0; | uint64_t fragmentation = 0; | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |