Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,814 Lines • ▼ Show 20 Lines | void PeerManager::ProcessMessage(const Config &config, CNode &pfrom, | ||||
if (gArgs.IsArgSet("-dropmessagestest") && | if (gArgs.IsArgSet("-dropmessagestest") && | ||||
GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0) { | GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0) { | ||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); | LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); | ||||
return; | return; | ||||
} | } | ||||
if (IsAvalancheMessageType(msg_type)) { | if (IsAvalancheMessageType(msg_type)) { | ||||
if (!g_avalanche) { | if (!g_avalanche) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::AVALANCHE, | ||||
"Avalanche is not initialized, ignoring %s message\n", | "Avalanche is not initialized, ignoring %s message\n", | ||||
msg_type); | msg_type); | ||||
return; | return; | ||||
} | } | ||||
if (!isAvalancheEnabled(gArgs)) { | if (!isAvalancheEnabled(gArgs)) { | ||||
Misbehaving(pfrom, 20, "unsolicited-" + msg_type); | Misbehaving(pfrom, 20, "unsolicited-" + msg_type); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::VERACK) { | ||||
msgMaker.Make(NetMsgType::SENDCMPCT, | msgMaker.Make(NetMsgType::SENDCMPCT, | ||||
fAnnounceUsingCMPCTBLOCK, | fAnnounceUsingCMPCTBLOCK, | ||||
nCMPCTBLOCKVersion)); | nCMPCTBLOCKVersion)); | ||||
} | } | ||||
if ((pfrom.nServices & NODE_AVALANCHE) && g_avalanche && | if ((pfrom.nServices & NODE_AVALANCHE) && g_avalanche && | ||||
isAvalancheEnabled(gArgs)) { | isAvalancheEnabled(gArgs)) { | ||||
if (g_avalanche->sendHello(&pfrom)) { | if (g_avalanche->sendHello(&pfrom)) { | ||||
LogPrint(BCLog::NET, "Send avahello to peer %d\n", | LogPrint(BCLog::AVALANCHE, "Send avahello to peer %d\n", | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
auto localProof = g_avalanche->getLocalProof(); | auto localProof = g_avalanche->getLocalProof(); | ||||
// If we sent a hello message, we should have a proof | // If we sent a hello message, we should have a proof | ||||
assert(localProof); | assert(localProof); | ||||
// Add our proof id to the list or the recently announced proof | // Add our proof id to the list or the recently announced proof | ||||
// INVs to this peer. This is used for filtering which INV can | // INVs to this peer. This is used for filtering which INV can | ||||
▲ Show 20 Lines • Show All 1,142 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPOLL) { | ||||
pfrom, 20, | pfrom, 20, | ||||
strprintf("too-many-ava-poll: poll message size = %u", nCount)); | strprintf("too-many-ava-poll: poll message size = %u", nCount)); | ||||
return; | return; | ||||
} | } | ||||
std::vector<avalanche::Vote> votes; | std::vector<avalanche::Vote> votes; | ||||
votes.reserve(nCount); | votes.reserve(nCount); | ||||
LogPrint(BCLog::NET, "received avalanche poll from peer=%d\n", | LogPrint(BCLog::AVALANCHE, "received avalanche poll from peer=%d\n", | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
for (unsigned int n = 0; n < nCount; n++) { | for (unsigned int n = 0; n < nCount; n++) { | ||||
CInv inv; | CInv inv; | ||||
vRecv >> inv; | vRecv >> inv; | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVARESPONSE) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UnparkBlock(pindex); | UnparkBlock(pindex); | ||||
} break; | } break; | ||||
} | } | ||||
} | } | ||||
BlockValidationState state; | BlockValidationState state; | ||||
if (!ActivateBestChain(config, state)) { | if (!ActivateBestChain(config, state)) { | ||||
LogPrint(BCLog::NET, "failed to activate chain (%s)\n", | LogPrintf("failed to activate chain (%s)\n", state.ToString()); | ||||
state.ToString()); | |||||
} | } | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::AVAPROOF) { | if (msg_type == NetMsgType::AVAPROOF) { | ||||
auto proof = std::make_shared<avalanche::Proof>(); | auto proof = std::make_shared<avalanche::Proof>(); | ||||
▲ Show 20 Lines • Show All 1,386 Lines • ▼ Show 20 Lines | bool PeerManager::SendMessages(const Config &config, CNode *pto, | ||||
// Message: getdata (proof) | // Message: getdata (proof) | ||||
// | // | ||||
{ | { | ||||
LOCK(cs_proofrequest); | LOCK(cs_proofrequest); | ||||
std::vector<std::pair<NodeId, avalanche::ProofId>> expired; | std::vector<std::pair<NodeId, avalanche::ProofId>> expired; | ||||
auto requestable = | auto requestable = | ||||
m_proofrequest.GetRequestable(pto->GetId(), current_time, &expired); | m_proofrequest.GetRequestable(pto->GetId(), current_time, &expired); | ||||
for (const auto &entry : expired) { | for (const auto &entry : expired) { | ||||
LogPrint(BCLog::NET, "timeout of inflight proof %s from peer=%d\n", | LogPrint(BCLog::AVALANCHE, | ||||
"timeout of inflight proof %s from peer=%d\n", | |||||
entry.second.ToString(), entry.first); | entry.second.ToString(), entry.first); | ||||
} | } | ||||
for (const auto &proofid : requestable) { | for (const auto &proofid : requestable) { | ||||
if (!AlreadyHaveProof(proofid)) { | if (!AlreadyHaveProof(proofid)) { | ||||
addGetDataAndMaybeFlush(MSG_AVA_PROOF, proofid); | addGetDataAndMaybeFlush(MSG_AVA_PROOF, proofid); | ||||
m_proofrequest.RequestedData( | m_proofrequest.RequestedData( | ||||
pto->GetId(), proofid, | pto->GetId(), proofid, | ||||
current_time + PROOF_REQUEST_PARAMS.getdata_interval); | current_time + PROOF_REQUEST_PARAMS.getdata_interval); | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |