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,256 Lines • ▼ Show 20 Lines | |||||
bool IsAvalancheMessageType(const std::string &msg_type) { | bool IsAvalancheMessageType(const std::string &msg_type) { | ||||
return msg_type == NetMsgType::AVAHELLO || | return msg_type == NetMsgType::AVAHELLO || | ||||
msg_type == NetMsgType::AVAPOLL || | msg_type == NetMsgType::AVAPOLL || | ||||
msg_type == NetMsgType::AVARESPONSE || | msg_type == NetMsgType::AVARESPONSE || | ||||
msg_type == NetMsgType::AVAPROOF || | msg_type == NetMsgType::AVAPROOF || | ||||
msg_type == NetMsgType::GETAVAADDR || | msg_type == NetMsgType::GETAVAADDR || | ||||
msg_type == NetMsgType::GETAVAPROOFS || | msg_type == NetMsgType::GETAVAPROOFS || | ||||
msg_type == NetMsgType::AVAPROOFS; | msg_type == NetMsgType::AVAPROOFS || | ||||
msg_type == NetMsgType::AVAPROOFSREQ; | |||||
} | } | ||||
uint32_t PeerManagerImpl::GetAvalancheVoteForBlock(const BlockHash &hash) { | uint32_t PeerManagerImpl::GetAvalancheVoteForBlock(const BlockHash &hash) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
const CBlockIndex *pindex = m_chainman.m_blockman.LookupBlockIndex(hash); | const CBlockIndex *pindex = m_chainman.m_blockman.LookupBlockIndex(hash); | ||||
// Unknown block. | // Unknown block. | ||||
▲ Show 20 Lines • Show All 1,991 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPROOFS) { | ||||
} | } | ||||
} | } | ||||
m_connman.PushMessage(&pfrom, | m_connman.PushMessage(&pfrom, | ||||
msgMaker.Make(NetMsgType::AVAPROOFSREQ, req)); | msgMaker.Make(NetMsgType::AVAPROOFSREQ, req)); | ||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::AVAPROOFSREQ) { | |||||
if (pfrom.m_proof_relay == nullptr) { | |||||
return; | |||||
} | |||||
avalanche::ProofsRequest proofreq; | |||||
vRecv >> proofreq; | |||||
auto requestedIndiceIt = proofreq.indices.begin(); | |||||
uint32_t treeIndice = 0; | |||||
pfrom.m_proof_relay->sharedProofs.forEachLeaf([&](const auto &proof) { | |||||
if (requestedIndiceIt == proofreq.indices.end()) { | |||||
// No more indice to process | |||||
return false; | |||||
} | |||||
if (treeIndice++ == *requestedIndiceIt) { | |||||
m_connman.PushMessage( | |||||
&pfrom, msgMaker.Make(NetMsgType::AVAPROOF, *proof)); | |||||
requestedIndiceIt++; | |||||
} | |||||
return true; | |||||
}); | |||||
pfrom.m_proof_relay->sharedProofs = {}; | |||||
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 | ||||
// only make outgoing connections ignore the getaddr message mitigates | // only make outgoing connections ignore the getaddr message mitigates | ||||
// the attack. | // the attack. | ||||
if (!pfrom.IsInboundConn()) { | if (!pfrom.IsInboundConn()) { | ||||
▲ Show 20 Lines • Show All 1,738 Lines • Show Last 20 Lines |