Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 439 Lines • ▼ Show 20 Lines | NodeId PeerManager::selectNode() { | ||||
} | } | ||||
// We failed to find a node to query, flag this so we can request more | // We failed to find a node to query, flag this so we can request more | ||||
needMoreNodes = true; | needMoreNodes = true; | ||||
return NO_NODE; | return NO_NODE; | ||||
} | } | ||||
void 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 = ::ChainstateActive().CoinsTip(); | const CCoinsViewCache &coins = ::ChainstateActive().CoinsTip(); | ||||
for (const auto &p : peers) { | for (const auto &p : peers) { | ||||
Show All 9 Lines | std::unordered_set<ProofRef, SaltedProofHasher> PeerManager::updatedBlockTip() { | ||||
// Remove the invalid proofs before the orphans rescan. This makes it | // Remove the invalid proofs before the orphans rescan. This makes it | ||||
// possible to pull back proofs with utxos that conflicted with these | // possible to pull back proofs with utxos that conflicted with these | ||||
// invalid proofs. | // invalid proofs. | ||||
for (const ProofId &invalidProofId : invalidProofIds) { | for (const ProofId &invalidProofId : invalidProofIds) { | ||||
rejectProof(invalidProofId, RejectionMode::INVALIDATE); | rejectProof(invalidProofId, RejectionMode::INVALIDATE); | ||||
} | } | ||||
orphanProofPool.rescan(*this); | auto registeredProofs = orphanProofPool.rescan(*this); | ||||
for (auto &p : newOrphans) { | for (auto &p : newOrphans) { | ||||
orphanProofPool.addProofIfPreferred(p); | orphanProofPool.addProofIfPreferred(p); | ||||
} | } | ||||
return registeredProofs; | |||||
} | } | ||||
ProofRef PeerManager::getProof(const ProofId &proofid) const { | ProofRef PeerManager::getProof(const ProofId &proofid) const { | ||||
ProofRef proof; | ProofRef proof; | ||||
forPeer(proofid, [&](const Peer &p) { | forPeer(proofid, [&](const Peer &p) { | ||||
proof = p.proof; | proof = p.proof; | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 329 Lines • Show Last 20 Lines |