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 5,278 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVARESPONSE) { | ||||
LogPrintf("failed to activate chain (%s)\n", state.ToString()); | LogPrintf("failed to activate chain (%s)\n", state.ToString()); | ||||
} | } | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::AVAPROOF) { | if (msg_type == NetMsgType::AVAPROOF) { | ||||
auto proof = std::make_shared<avalanche::Proof>(); | avalanche::Proof p; | ||||
vRecv >> *proof; | vRecv >> p; | ||||
const avalanche::ProofId &proofid = proof->getId(); | const avalanche::ProofId &proofid = p.getId(); | ||||
pfrom.AddKnownProof(proofid); | pfrom.AddKnownProof(proofid); | ||||
const NodeId nodeid = pfrom.GetId(); | const NodeId nodeid = pfrom.GetId(); | ||||
{ | { | ||||
LOCK(cs_proofrequest); | LOCK(cs_proofrequest); | ||||
m_proofrequest.ReceivedResponse(nodeid, proofid); | m_proofrequest.ReceivedResponse(nodeid, proofid); | ||||
if (AlreadyHaveProof(proofid)) { | if (AlreadyHaveProof(proofid)) { | ||||
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 | ||||
auto proof = avalanche::ProofRef::make(std::move(p)); | |||||
avalanche::ProofRegistrationState state; | avalanche::ProofRegistrationState state; | ||||
if (g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | if (g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
return pm.registerProof(proof, state); | 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.m_last_proof_time = GetTime<std::chrono::seconds>(); | pfrom.m_last_proof_time = GetTime<std::chrono::seconds>(); | ||||
▲ Show 20 Lines • Show All 1,723 Lines • Show Last 20 Lines |