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,391 Lines • ▼ Show 20 Lines | static void 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; | |||||
} | } | ||||
/** | /** | ||||
* Decide a response for an Avalanche poll about the given block. | * Decide a response for an Avalanche poll about the given block. | ||||
* | * | ||||
* @param[in] hash The hash of the block being polled for | * @param[in] hash The hash of the block being polled for | ||||
* @param[out] uint32_t Our current vote for the block | * @param[out] uint32_t Our current vote for the block | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,914 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::AVAPROOF) { | ||||
} | } | ||||
LogPrint(BCLog::AVALANCHE, | LogPrint(BCLog::AVALANCHE, | ||||
"Not polling the avalanche proof (%s): peer=%d, proofid %s\n", | "Not polling the avalanche proof (%s): peer=%d, proofid %s\n", | ||||
state.GetRejectReason(), nodeid, proofid.ToString()); | state.GetRejectReason(), nodeid, proofid.ToString()); | ||||
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,684 Lines • Show Last 20 Lines |