Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,762 Lines • ▼ Show 20 Lines | void PeerManager::ProcessMessage(const Config &config, CNode &pfrom, | ||||
if (IsAvalancheMessageType(msg_type)) { | if (IsAvalancheMessageType(msg_type)) { | ||||
if (!g_avalanche) { | if (!g_avalanche) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"Avalanche is not initialized, ignoring %s message\n", | "Avalanche is not initialized, ignoring %s message\n", | ||||
msg_type); | msg_type); | ||||
return; | return; | ||||
} | } | ||||
if (!gArgs.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | if (!isAvalancheEnabled(gArgs)) { | ||||
Misbehaving(pfrom, 20, "unsolicited-" + msg_type); | Misbehaving(pfrom, 20, "unsolicited-" + msg_type); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
if (msg_type == NetMsgType::VERSION) { | if (msg_type == NetMsgType::VERSION) { | ||||
// Each connection can only send one version message | // Each connection can only send one version message | ||||
if (pfrom.nVersion != 0) { | if (pfrom.nVersion != 0) { | ||||
▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::VERACK) { | ||||
uint64_t nCMPCTBLOCKVersion = 1; | uint64_t nCMPCTBLOCKVersion = 1; | ||||
m_connman.PushMessage(&pfrom, | m_connman.PushMessage(&pfrom, | ||||
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 && | ||||
gArgs.GetBoolArg("-enableavalanche", AVALANCHE_DEFAULT_ENABLED)) { | isAvalancheEnabled(gArgs)) { | ||||
if (g_avalanche->sendHello(&pfrom)) { | if (g_avalanche->sendHello(&pfrom)) { | ||||
LogPrint(BCLog::NET, "Send avahello to peer %d\n", | LogPrint(BCLog::NET, "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); | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::INV) { | ||||
continue; | continue; | ||||
} | } | ||||
if (inv.IsMsgProof()) { | if (inv.IsMsgProof()) { | ||||
const avalanche::ProofId proofid(inv.hash); | const avalanche::ProofId proofid(inv.hash); | ||||
const bool fAlreadyHave = AlreadyHaveProof(proofid); | const bool fAlreadyHave = AlreadyHaveProof(proofid); | ||||
logInv(inv, fAlreadyHave); | logInv(inv, fAlreadyHave); | ||||
if (!fAlreadyHave && g_avalanche && | if (!fAlreadyHave && g_avalanche && isAvalancheEnabled(gArgs)) { | ||||
gArgs.GetBoolArg("-enableavalanche", | |||||
AVALANCHE_DEFAULT_ENABLED)) { | |||||
const bool preferred = isPreferredDownloadPeer(pfrom); | const bool preferred = isPreferredDownloadPeer(pfrom); | ||||
LOCK(cs_proofrequest); | LOCK(cs_proofrequest); | ||||
AddProofAnnouncement(pfrom, proofid, current_time, | AddProofAnnouncement(pfrom, proofid, current_time, | ||||
preferred); | preferred); | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,534 Lines • Show Last 20 Lines |