Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | bool PeerManager::registerProof(const ProofRef &proof) { | ||||
// Check the proof's validity. | // Check the proof's validity. | ||||
ProofValidationState state; | ProofValidationState state; | ||||
// Using WITH_LOCK directly inside the if statement will trigger a cppcheck | // Using WITH_LOCK directly inside the if statement will trigger a cppcheck | ||||
// false positive syntax error | // false positive syntax error | ||||
const bool valid = WITH_LOCK( | const bool valid = WITH_LOCK( | ||||
cs_main, return proof->verify(state, ::ChainstateActive().CoinsTip())); | cs_main, return proof->verify(state, ::ChainstateActive().CoinsTip())); | ||||
if (!valid) { | if (!valid) { | ||||
if (isOrphanState(state)) { | if (isOrphanState(state)) { | ||||
orphanProofPool.addProofIfNoConflict(proof); | orphanProofPool.addProofIfPreferred(proof); | ||||
} | } | ||||
// Reject invalid proof. | // Reject invalid proof. | ||||
return false; | return false; | ||||
} | } | ||||
return createPeer(proof); | return createPeer(proof); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | for (const auto &pid : invalidPeers) { | ||||
conflictingProofPool.removeProof(conflictingProof); | conflictingProofPool.removeProof(conflictingProof); | ||||
registerProof(conflictingProof); | registerProof(conflictingProof); | ||||
} | } | ||||
} | } | ||||
orphanProofPool.rescan(*this); | orphanProofPool.rescan(*this); | ||||
for (auto &p : newOrphans) { | for (auto &p : newOrphans) { | ||||
orphanProofPool.addProofIfNoConflict(p); | orphanProofPool.addProofIfPreferred(p); | ||||
} | } | ||||
} | } | ||||
ProofRef PeerManager::getProof(const ProofId &proofid) const { | ProofRef PeerManager::getProof(const ProofId &proofid) const { | ||||
ProofRef proof = nullptr; | ProofRef proof = nullptr; | ||||
forPeer(proofid, [&](const Peer &p) { | forPeer(proofid, [&](const Peer &p) { | ||||
proof = p.proof; | proof = p.proof; | ||||
▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines |