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.
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <net_processing.h> | #include <net_processing.h> | ||||
#include <addrman.h> | #include <addrman.h> | ||||
#include <avalanche/avalanche.h> | #include <avalanche/avalanche.h> | ||||
#include <avalanche/compactproofs.h> | |||||
#include <avalanche/peermanager.h> | #include <avalanche/peermanager.h> | ||||
#include <avalanche/processor.h> | #include <avalanche/processor.h> | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <avalanche/validation.h> | #include <avalanche/validation.h> | ||||
#include <banman.h> | #include <banman.h> | ||||
#include <blockdb.h> | #include <blockdb.h> | ||||
#include <blockencodings.h> | #include <blockencodings.h> | ||||
#include <blockfilter.h> | #include <blockfilter.h> | ||||
▲ Show 20 Lines • Show All 3,236 Lines • ▼ Show 20 Lines | void PeerManagerImpl::ProcessGetCFCheckPt(CNode &peer, CDataStream &vRecv, | ||||
connman.PushMessage(&peer, std::move(msg)); | connman.PushMessage(&peer, std::move(msg)); | ||||
} | } | ||||
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; | |||||
} | } | ||||
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,868 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPROOF) { | ||||
auto proof = RCUPtr<avalanche::Proof>::make(); | auto proof = RCUPtr<avalanche::Proof>::make(); | ||||
vRecv >> *proof; | vRecv >> *proof; | ||||
ReceivedAvalancheProof(pfrom, proof); | ReceivedAvalancheProof(pfrom, proof); | ||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::GETAVAPROOFS) { | |||||
if (pfrom.m_proof_relay == nullptr) { | |||||
return; | |||||
} | |||||
pfrom.m_proof_relay->sharedProofs = | |||||
g_avalanche->withPeerManager([&](const avalanche::PeerManager &pm) { | |||||
return pm.getShareableProofsSnapshot(); | |||||
}); | |||||
avalanche::CompactProofs compactProofs( | |||||
pfrom.m_proof_relay->sharedProofs); | |||||
m_connman.PushMessage( | |||||
&pfrom, msgMaker.Make(NetMsgType::AVAPROOFS, compactProofs)); | |||||
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 |