Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show All 15 Lines | struct Slot { | ||||
uint64_t stop; | uint64_t stop; | ||||
Slot(uint64_t startIn, uint64_t stopIn) : start(startIn), stop(stopIn) {} | Slot(uint64_t startIn, uint64_t stopIn) : start(startIn), stop(stopIn) {} | ||||
}; | }; | ||||
class PeerManager { | class PeerManager { | ||||
std::vector<Slot> slots; | std::vector<Slot> slots; | ||||
uint64_t slotCount = 0; | uint64_t slotCount = 0; | ||||
uint64_t fragmentation = 0; | |||||
public: | public: | ||||
void addPeer(uint64_t score); | void addPeer(uint64_t score); | ||||
void rescorePeer(size_t i, uint64_t score); | |||||
void removePeer(size_t i) { rescorePeer(i, 0); } | |||||
size_t selectPeer() const; | size_t selectPeer() const; | ||||
// Accssors. | |||||
uint64_t getSlotCount() const { return slotCount; } | |||||
uint64_t getFragmentation() const { return fragmentation; } | |||||
}; | }; | ||||
/** | /** | ||||
* This is an internal method that is exposed for testing purposes. | * This is an internal method that is exposed for testing purposes. | ||||
*/ | */ | ||||
size_t selectPeerImpl(const std::vector<Slot> &slots, const uint64_t slot, | size_t selectPeerImpl(const std::vector<Slot> &slots, const uint64_t slot, | ||||
const uint64_t max); | const uint64_t max); | ||||
#endif // BITCOIN_AVALANCHE_PEERMANAGER_H | #endif // BITCOIN_AVALANCHE_PEERMANAGER_H |