Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 4,366 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPROOF) { | ||||
if (AlreadyHaveProof(proofid)) { | if (AlreadyHaveProof(proofid)) { | ||||
m_proofrequest.ForgetInvId(proofid); | m_proofrequest.ForgetInvId(proofid); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
// addProof should not be called while cs_proofrequest because it holds | // addProof should not be called while cs_proofrequest because it holds | ||||
// cs_main and that creates a potential deadlock during shutdown | // cs_main and that creates a potential deadlock during shutdown | ||||
if (g_avalanche->addProof(proof)) { | g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
if (pm.registerProof(proof)) { | |||||
WITH_LOCK(cs_proofrequest, m_proofrequest.ForgetInvId(proofid)); | WITH_LOCK(cs_proofrequest, m_proofrequest.ForgetInvId(proofid)); | ||||
RelayProof(proofid, m_connman); | RelayProof(proofid, m_connman); | ||||
LogPrint(BCLog::NET, "New avalanche proof: peer=%d, proofid %s\n", | LogPrint(BCLog::NET, | ||||
nodeid, proofid.ToString()); | "New avalanche proof: peer=%d, proofid %s\n", nodeid, | ||||
proofid.ToString()); | |||||
} else { | } else { | ||||
// If the proof couldn't be added, it can be either orphan or | // If the proof couldn't be added, it can be either orphan or | ||||
// invalid. In the latter case we should increase the ban score. | // invalid. In the latter case we should increase the ban score. | ||||
// TODO improve the ban reason by printing the validation state | // TODO improve the ban reason by printing the validation state | ||||
if (!g_avalanche->getOrphan(proofid)) { | if (!pm.getOrphan(proofid)) { | ||||
WITH_LOCK(cs_rejectedProofs, rejectedProofs->insert(proofid)); | WITH_LOCK(cs_rejectedProofs, | ||||
rejectedProofs->insert(proofid)); | |||||
Misbehaving(nodeid, 100, "invalid-avaproof"); | Misbehaving(nodeid, 100, "invalid-avaproof"); | ||||
} | } | ||||
} | } | ||||
}); | |||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::GETADDR) { | if (msg_type == NetMsgType::GETADDR) { | ||||
// This asymmetric behavior for inbound and outbound connections was | // This asymmetric behavior for inbound and outbound connections was | ||||
// introduced to prevent a fingerprinting attack: an attacker can send | // introduced to prevent a fingerprinting attack: an attacker can send | ||||
// specific fake addresses to users' AddrMan and later request them by | // specific fake addresses to users' AddrMan and later request them by | ||||
// sending getaddr messages. Making nodes which are behind NAT and can | // sending getaddr messages. Making nodes which are behind NAT and can | ||||
▲ Show 20 Lines • Show All 1,472 Lines • Show Last 20 Lines |