Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,934 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPROOF) { | ||||
m_proofrequest.ForgetInvId(proofid); | m_proofrequest.ForgetInvId(proofid); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
// registerProof should not be called while cs_proofrequest because it | // registerProof should not be called while cs_proofrequest because it | ||||
// holds cs_main and that creates a potential deadlock during shutdown | // holds cs_main and that creates a potential deadlock during shutdown | ||||
avalanche::ProofRegistrationState state; | |||||
if (g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | if (g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
return pm.registerProof(proof); | return pm.registerProof(proof, state); | ||||
})) { | })) { | ||||
WITH_LOCK(cs_proofrequest, m_proofrequest.ForgetInvId(proofid)); | WITH_LOCK(cs_proofrequest, m_proofrequest.ForgetInvId(proofid)); | ||||
RelayProof(proofid, m_connman); | RelayProof(proofid, m_connman); | ||||
pfrom.nLastProofTime = GetTime(); | pfrom.nLastProofTime = GetTime(); | ||||
LogPrint(BCLog::NET, "New avalanche proof: peer=%d, proofid %s\n", | LogPrint(BCLog::NET, "New avalanche proof: peer=%d, proofid %s\n", | ||||
nodeid, proofid.ToString()); | nodeid, proofid.ToString()); | ||||
} else { | |||||
// If the proof couldn't be added, it can be either orphan or | |||||
// invalid. In the latter case we should increase the ban score. | |||||
// TODO improve the ban reason by printing the validation state | |||||
if (!g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | |||||
return pm.isOrphan(proofid); | |||||
})) { | |||||
WITH_LOCK(cs_rejectedProofs, rejectedProofs->insert(proofid)); | |||||
Misbehaving(nodeid, 100, "invalid-avaproof"); | |||||
} | } | ||||
if (state.GetResult() == avalanche::ProofRegistrationResult::INVALID) { | |||||
WITH_LOCK(cs_rejectedProofs, rejectedProofs->insert(proofid)); | |||||
Misbehaving(nodeid, 100, state.GetRejectReason()); | |||||
} | } | ||||
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,635 Lines • Show Last 20 Lines |