Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | struct Peer { | ||||
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 registration_time; | ||||
std::chrono::seconds nextPossibleConflictTime; | std::chrono::seconds nextPossibleConflictTime; | ||||
Peer(PeerId peerid_, ProofRef proof_) | Peer(PeerId peerid_, ProofRef proof_, | ||||
std::chrono::seconds nextPossibleConflictTime_) | |||||
: peerid(peerid_), proof(std::move(proof_)), | : peerid(peerid_), proof(std::move(proof_)), | ||||
registration_time(GetTime<std::chrono::seconds>()), | registration_time(GetTime<std::chrono::seconds>()), | ||||
nextPossibleConflictTime(registration_time) {} | 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; | ||||
result_type operator()(const Peer &p) const { return p.proof->getId(); } | result_type operator()(const Peer &p) const { return p.proof->getId(); } | ||||
Show All 14 Lines | |||||
enum class ProofRegistrationResult { | enum class ProofRegistrationResult { | ||||
NONE = 0, | NONE = 0, | ||||
ALREADY_REGISTERED, | ALREADY_REGISTERED, | ||||
ORPHAN, | ORPHAN, | ||||
INVALID, | INVALID, | ||||
CONFLICTING, | CONFLICTING, | ||||
REJECTED, | REJECTED, | ||||
COOLDOWN_NOT_ELAPSED, | |||||
}; | }; | ||||
class ProofRegistrationState : public ValidationState<ProofRegistrationResult> { | class ProofRegistrationState : public ValidationState<ProofRegistrationResult> { | ||||
}; | }; | ||||
namespace bmi = boost::multi_index; | namespace bmi = boost::multi_index; | ||||
class PeerManager { | class PeerManager { | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |