Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 405 Lines • ▼ Show 20 Lines | bool PeerManager::rejectProof(const ProofId &proofid, RejectionMode mode) { | ||||
if (mode == RejectionMode::DEFAULT) { | if (mode == RejectionMode::DEFAULT) { | ||||
conflictingProofPool.addProofIfPreferred(proof); | conflictingProofPool.addProofIfPreferred(proof); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void PeerManager::cleanupDanglingProofs() { | void PeerManager::cleanupDanglingProofs(const ProofRef &localProof) { | ||||
const auto now = GetTime<std::chrono::seconds>(); | const auto now = GetTime<std::chrono::seconds>(); | ||||
std::vector<ProofId> newlyDanglingProofIds; | std::vector<ProofId> newlyDanglingProofIds; | ||||
for (const Peer &peer : peers) { | for (const Peer &peer : peers) { | ||||
// If the peer has been registered for some time and has no node | // If the peer is not our local proof, has been registered for some | ||||
// attached, discard it. | // time and has no node attached, discard it. | ||||
if (peer.node_count == 0 && | if ((!localProof || peer.getProofId() != localProof->getId()) && | ||||
peer.node_count == 0 && | |||||
(peer.registration_time + Peer::DANGLING_TIMEOUT) <= now) { | (peer.registration_time + Peer::DANGLING_TIMEOUT) <= now) { | ||||
newlyDanglingProofIds.push_back(peer.getProofId()); | newlyDanglingProofIds.push_back(peer.getProofId()); | ||||
} | } | ||||
} | } | ||||
for (const ProofId &proofid : newlyDanglingProofIds) { | for (const ProofId &proofid : newlyDanglingProofIds) { | ||||
rejectProof(proofid, RejectionMode::INVALIDATE); | rejectProof(proofid, RejectionMode::INVALIDATE); | ||||
danglingProofIds.insert(proofid); | danglingProofIds.insert(proofid); | ||||
▲ Show 20 Lines • Show All 381 Lines • Show Last 20 Lines |