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 3,725 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::VERACK) { | ||||
} | } | ||||
if (g_avalanche && isAvalancheEnabled(gArgs)) { | if (g_avalanche && isAvalancheEnabled(gArgs)) { | ||||
if (g_avalanche->sendHello(&pfrom)) { | if (g_avalanche->sendHello(&pfrom)) { | ||||
LogPrint(BCLog::AVALANCHE, "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 | |||||
assert(localProof); | |||||
// Add our proof id to the list or the recently announced proof | if (localProof) { | ||||
// INVs to this peer. This is used for filtering which INV can | // Add our proof id to the list or the recently announced | ||||
// be requested for download. | // proof INVs to this peer. This is used for filtering which | ||||
// INV can be requested for download. | |||||
LOCK(cs_main); | LOCK(cs_main); | ||||
State(pfrom.GetId()) | State(pfrom.GetId()) | ||||
->m_recently_announced_proofs.insert(localProof->getId()); | ->m_recently_announced_proofs.insert( | ||||
localProof->getId()); | |||||
} | |||||
} | } | ||||
// Send getavaaddr and getavaproofs to our avalanche outbound or | // Send getavaaddr and getavaproofs to our avalanche outbound or | ||||
// manual connections | // manual connections | ||||
if (isAvalancheOutboundOrManual(&pfrom)) { | if (isAvalancheOutboundOrManual(&pfrom)) { | ||||
m_connman.PushMessage(&pfrom, | m_connman.PushMessage(&pfrom, | ||||
msgMaker.Make(NetMsgType::GETAVAADDR)); | msgMaker.Make(NetMsgType::GETAVAADDR)); | ||||
WITH_LOCK(peer->m_addr_token_bucket_mutex, | WITH_LOCK(peer->m_addr_token_bucket_mutex, | ||||
▲ Show 20 Lines • Show All 1,174 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAHELLO) { | ||||
return; | return; | ||||
} | } | ||||
pfrom.m_avalanche_state = std::make_unique<CNode::AvalancheState>(); | pfrom.m_avalanche_state = std::make_unique<CNode::AvalancheState>(); | ||||
avalanche::Delegation delegation; | avalanche::Delegation delegation; | ||||
vRecv >> delegation; | vRecv >> delegation; | ||||
// A delegation with an all zero limited id indicates that the peer has | |||||
// no proof, so we're done. | |||||
if (delegation.getLimitedProofId() == uint256::ZERO) { | |||||
return; | |||||
} | |||||
avalanche::DelegationState state; | avalanche::DelegationState state; | ||||
CPubKey &pubkey = pfrom.m_avalanche_state->pubkey; | CPubKey &pubkey = pfrom.m_avalanche_state->pubkey; | ||||
if (!delegation.verify(state, pubkey)) { | if (!delegation.verify(state, pubkey)) { | ||||
Misbehaving(pfrom, 100, "invalid-delegation"); | Misbehaving(pfrom, 100, "invalid-delegation"); | ||||
return; | return; | ||||
} | } | ||||
CHashWriter sighasher(SER_GETHASH, 0); | CHashWriter sighasher(SER_GETHASH, 0); | ||||
▲ Show 20 Lines • Show All 2,173 Lines • Show Last 20 Lines |