Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | bool PeerManager::registerProof(const ProofRef &proof, | ||||
} | } | ||||
// Check the proof's validity. | // Check the proof's validity. | ||||
ProofValidationState validationState; | ProofValidationState validationState; | ||||
if (!WITH_LOCK(cs_main, | if (!WITH_LOCK(cs_main, | ||||
return proof->verify(validationState, | return proof->verify(validationState, | ||||
::ChainstateActive().CoinsTip()))) { | ::ChainstateActive().CoinsTip()))) { | ||||
if (isOrphanState(validationState)) { | if (isOrphanState(validationState)) { | ||||
// Only accept orphan proofs if there's room in the orphan pool. | |||||
auto status = orphanProofPool.addProofIfNoConflict(proof); | |||||
if (status != ProofPool::AddProofStatus::SUCCEED) { | |||||
// Attempt proof replacement | |||||
orphanProofPool.addProofIfPreferred(proof); | orphanProofPool.addProofIfPreferred(proof); | ||||
} else if (orphanProofPool.countProofs() > | |||||
AVALANCHE_MAX_ORPHAN_PROOFS) { | |||||
// Adding this proof exceeds the orphan pool limit, so remove | |||||
// it. | |||||
orphanProofPool.removeProof(proof->getId()); | |||||
} | |||||
return invalidate(ProofRegistrationResult::ORPHAN, "orphan-proof"); | return invalidate(ProofRegistrationResult::ORPHAN, "orphan-proof"); | ||||
} | } | ||||
// Reject invalid proof. | // Reject invalid proof. | ||||
return invalidate(ProofRegistrationResult::INVALID, "invalid-proof"); | return invalidate(ProofRegistrationResult::INVALID, "invalid-proof"); | ||||
} | } | ||||
auto now = GetTime<std::chrono::seconds>(); | auto now = GetTime<std::chrono::seconds>(); | ||||
▲ Show 20 Lines • Show All 538 Lines • Show Last 20 Lines |