Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | if (danglingProofIds.contains(proofid) && | ||||
pendingNodes.count(proofid) == 0) { | pendingNodes.count(proofid) == 0) { | ||||
// Don't attempt to register a proof that we already evicted because it | // Don't attempt to register a proof that we already evicted because it | ||||
// was dangling. | // was dangling. | ||||
return invalidate(ProofRegistrationResult::DANGLING, "dangling-proof"); | return invalidate(ProofRegistrationResult::DANGLING, "dangling-proof"); | ||||
} | } | ||||
// Check the proof's validity. | // Check the proof's validity. | ||||
ProofValidationState validationState; | ProofValidationState validationState; | ||||
if (!WITH_LOCK(cs_main, return proof->verify( | if (!WITH_LOCK(cs_main, return proof->verify(validationState, chainman))) { | ||||
validationState, | |||||
chainman.ActiveChainstate().CoinsTip()))) { | |||||
if (isOrphanState(validationState)) { | if (isOrphanState(validationState)) { | ||||
orphanProofPool.addProofIfPreferred(proof); | orphanProofPool.addProofIfPreferred(proof); | ||||
if (orphanProofPool.countProofs() > AVALANCHE_MAX_ORPHAN_PROOFS) { | if (orphanProofPool.countProofs() > AVALANCHE_MAX_ORPHAN_PROOFS) { | ||||
// Adding this proof exceeds the orphan pool limit, so evict | // Adding this proof exceeds the orphan pool limit, so evict | ||||
// the lowest scoring proof. | // the lowest scoring proof. | ||||
orphanProofPool.removeProof( | orphanProofPool.removeProof( | ||||
orphanProofPool.getLowestScoreProof()->getId()); | orphanProofPool.getLowestScoreProof()->getId()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | |||||
std::unordered_set<ProofRef, SaltedProofHasher> PeerManager::updatedBlockTip() { | std::unordered_set<ProofRef, SaltedProofHasher> PeerManager::updatedBlockTip() { | ||||
std::vector<ProofId> invalidProofIds; | std::vector<ProofId> invalidProofIds; | ||||
std::vector<ProofRef> newOrphans; | std::vector<ProofRef> newOrphans; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CCoinsViewCache &coins = chainman.ActiveChainstate().CoinsTip(); | |||||
for (const auto &p : peers) { | for (const auto &p : peers) { | ||||
ProofValidationState state; | ProofValidationState state; | ||||
if (!p.proof->verify(state, coins)) { | if (!p.proof->verify(state, chainman)) { | ||||
if (isOrphanState(state)) { | if (isOrphanState(state)) { | ||||
newOrphans.push_back(p.proof); | newOrphans.push_back(p.proof); | ||||
} | } | ||||
invalidProofIds.push_back(p.getProofId()); | invalidProofIds.push_back(p.getProofId()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 333 Lines • Show Last 20 Lines |