mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
[net processing] Remove CNode::nLocalServices
This commit is contained in:
parent
5961f8eea1
commit
8d8eeb422e
10 changed files with 65 additions and 87 deletions
10
src/net.cpp
10
src/net.cpp
|
@ -541,7 +541,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||||
addr_bind = GetBindAddress(*sock);
|
addr_bind = GetBindAddress(*sock);
|
||||||
}
|
}
|
||||||
CNode* pnode = new CNode(id,
|
CNode* pnode = new CNode(id,
|
||||||
nLocalServices,
|
|
||||||
std::move(sock),
|
std::move(sock),
|
||||||
addrConnect,
|
addrConnect,
|
||||||
CalculateKeyedNetGroup(addrConnect),
|
CalculateKeyedNetGroup(addrConnect),
|
||||||
|
@ -1011,7 +1010,6 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
|
||||||
|
|
||||||
const bool inbound_onion = std::find(m_onion_binds.begin(), m_onion_binds.end(), addr_bind) != m_onion_binds.end();
|
const bool inbound_onion = std::find(m_onion_binds.begin(), m_onion_binds.end(), addr_bind) != m_onion_binds.end();
|
||||||
CNode* pnode = new CNode(id,
|
CNode* pnode = new CNode(id,
|
||||||
nodeServices,
|
|
||||||
std::move(sock),
|
std::move(sock),
|
||||||
addr,
|
addr,
|
||||||
CalculateKeyedNetGroup(addr),
|
CalculateKeyedNetGroup(addr),
|
||||||
|
@ -2705,7 +2703,10 @@ ServiceFlags CConnman::GetLocalServices() const
|
||||||
|
|
||||||
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
|
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
|
||||||
|
|
||||||
CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, std::shared_ptr<Sock> sock, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool inbound_onion)
|
CNode::CNode(NodeId idIn, std::shared_ptr<Sock> sock, const CAddress& addrIn,
|
||||||
|
uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn,
|
||||||
|
const CAddress& addrBindIn, const std::string& addrNameIn,
|
||||||
|
ConnectionType conn_type_in, bool inbound_onion)
|
||||||
: m_sock{sock},
|
: m_sock{sock},
|
||||||
m_connected{GetTime<std::chrono::seconds>()},
|
m_connected{GetTime<std::chrono::seconds>()},
|
||||||
addr(addrIn),
|
addr(addrIn),
|
||||||
|
@ -2715,8 +2716,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, std::shared_ptr<Sock> s
|
||||||
nKeyedNetGroup(nKeyedNetGroupIn),
|
nKeyedNetGroup(nKeyedNetGroupIn),
|
||||||
id(idIn),
|
id(idIn),
|
||||||
nLocalHostNonce(nLocalHostNonceIn),
|
nLocalHostNonce(nLocalHostNonceIn),
|
||||||
m_conn_type(conn_type_in),
|
m_conn_type(conn_type_in)
|
||||||
nLocalServices(nLocalServicesIn)
|
|
||||||
{
|
{
|
||||||
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
|
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
|
||||||
|
|
||||||
|
|
23
src/net.h
23
src/net.h
|
@ -513,7 +513,10 @@ public:
|
||||||
* criterium in CConnman::AttemptToEvictConnection. */
|
* criterium in CConnman::AttemptToEvictConnection. */
|
||||||
std::atomic<std::chrono::microseconds> m_min_ping_time{std::chrono::microseconds::max()};
|
std::atomic<std::chrono::microseconds> m_min_ping_time{std::chrono::microseconds::max()};
|
||||||
|
|
||||||
CNode(NodeId id, ServiceFlags nLocalServicesIn, std::shared_ptr<Sock> sock, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool inbound_onion);
|
CNode(NodeId id, std::shared_ptr<Sock> sock, const CAddress& addrIn,
|
||||||
|
uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn,
|
||||||
|
const CAddress& addrBindIn, const std::string& addrNameIn,
|
||||||
|
ConnectionType conn_type_in, bool inbound_onion);
|
||||||
CNode(const CNode&) = delete;
|
CNode(const CNode&) = delete;
|
||||||
CNode& operator=(const CNode&) = delete;
|
CNode& operator=(const CNode&) = delete;
|
||||||
|
|
||||||
|
@ -571,11 +574,6 @@ public:
|
||||||
|
|
||||||
void CopyStats(CNodeStats& stats) EXCLUSIVE_LOCKS_REQUIRED(!m_subver_mutex, !m_addr_local_mutex, !cs_vSend, !cs_vRecv);
|
void CopyStats(CNodeStats& stats) EXCLUSIVE_LOCKS_REQUIRED(!m_subver_mutex, !m_addr_local_mutex, !cs_vSend, !cs_vRecv);
|
||||||
|
|
||||||
ServiceFlags GetLocalServices() const
|
|
||||||
{
|
|
||||||
return nLocalServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
|
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
|
||||||
|
|
||||||
/** A ping-pong round trip has completed successfully. Update latest and minimum ping times. */
|
/** A ping-pong round trip has completed successfully. Update latest and minimum ping times. */
|
||||||
|
@ -590,9 +588,6 @@ private:
|
||||||
const ConnectionType m_conn_type;
|
const ConnectionType m_conn_type;
|
||||||
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
|
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
|
||||||
|
|
||||||
//! Services offered to this peer.
|
|
||||||
const ServiceFlags nLocalServices;
|
|
||||||
|
|
||||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||||
|
|
||||||
// Our address, as reported by the peer
|
// Our address, as reported by the peer
|
||||||
|
@ -1020,16 +1015,14 @@ private:
|
||||||
std::map<uint64_t, CachedAddrResponse> m_addr_response_caches;
|
std::map<uint64_t, CachedAddrResponse> m_addr_response_caches;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services this instance offers.
|
* Services this node offers.
|
||||||
*
|
*
|
||||||
* This data is replicated in each CNode instance we create during peer
|
* This data is replicated in each Peer instance we create.
|
||||||
* connection (in ConnectNode()) under a member also called
|
|
||||||
* nLocalServices.
|
|
||||||
*
|
*
|
||||||
* This data is not marked const, but after being set it should not
|
* This data is not marked const, but after being set it should not
|
||||||
* change. See the note in CNode::nLocalServices documentation.
|
* change.
|
||||||
*
|
*
|
||||||
* \sa CNode::nLocalServices
|
* \sa Peer::our_services
|
||||||
*/
|
*/
|
||||||
ServiceFlags nLocalServices;
|
ServiceFlags nLocalServices;
|
||||||
|
|
||||||
|
|
|
@ -219,9 +219,7 @@ struct Peer {
|
||||||
* to serve, but still advertises NODE_NETWORK because it will eventually
|
* to serve, but still advertises NODE_NETWORK because it will eventually
|
||||||
* fulfill this role after IBD completes. P2P code is written in such a
|
* fulfill this role after IBD completes. P2P code is written in such a
|
||||||
* way that it can gracefully handle peers who don't make good on their
|
* way that it can gracefully handle peers who don't make good on their
|
||||||
* service advertisements.
|
* service advertisements. */
|
||||||
*
|
|
||||||
* TODO: remove redundant CNode::nLocalServices*/
|
|
||||||
const ServiceFlags m_our_services;
|
const ServiceFlags m_our_services;
|
||||||
/** Services this peer offered to us. */
|
/** Services this peer offered to us. */
|
||||||
std::atomic<ServiceFlags> m_their_services{NODE_NONE};
|
std::atomic<ServiceFlags> m_their_services{NODE_NONE};
|
||||||
|
@ -867,6 +865,7 @@ private:
|
||||||
*
|
*
|
||||||
* May disconnect from the peer in the case of a bad request.
|
* May disconnect from the peer in the case of a bad request.
|
||||||
*
|
*
|
||||||
|
* @param[in] node The node that we received the request from
|
||||||
* @param[in] peer The peer that we received the request from
|
* @param[in] peer The peer that we received the request from
|
||||||
* @param[in] filter_type The filter type the request is for. Must be basic filters.
|
* @param[in] filter_type The filter type the request is for. Must be basic filters.
|
||||||
* @param[in] start_height The start height for the request
|
* @param[in] start_height The start height for the request
|
||||||
|
@ -876,7 +875,7 @@ private:
|
||||||
* @param[out] filter_index The filter index, if the request can be serviced.
|
* @param[out] filter_index The filter index, if the request can be serviced.
|
||||||
* @return True if the request can be serviced.
|
* @return True if the request can be serviced.
|
||||||
*/
|
*/
|
||||||
bool PrepareBlockFilterRequest(CNode& peer,
|
bool PrepareBlockFilterRequest(CNode& node, Peer& peer,
|
||||||
BlockFilterType filter_type, uint32_t start_height,
|
BlockFilterType filter_type, uint32_t start_height,
|
||||||
const uint256& stop_hash, uint32_t max_height_diff,
|
const uint256& stop_hash, uint32_t max_height_diff,
|
||||||
const CBlockIndex*& stop_index,
|
const CBlockIndex*& stop_index,
|
||||||
|
@ -887,30 +886,33 @@ private:
|
||||||
*
|
*
|
||||||
* May disconnect from the peer in the case of a bad request.
|
* May disconnect from the peer in the case of a bad request.
|
||||||
*
|
*
|
||||||
|
* @param[in] node The node that we received the request from
|
||||||
* @param[in] peer The peer that we received the request from
|
* @param[in] peer The peer that we received the request from
|
||||||
* @param[in] vRecv The raw message received
|
* @param[in] vRecv The raw message received
|
||||||
*/
|
*/
|
||||||
void ProcessGetCFilters(CNode& peer, CDataStream& vRecv);
|
void ProcessGetCFilters(CNode& node, Peer& peer, CDataStream& vRecv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a cfheaders request.
|
* Handle a cfheaders request.
|
||||||
*
|
*
|
||||||
* May disconnect from the peer in the case of a bad request.
|
* May disconnect from the peer in the case of a bad request.
|
||||||
*
|
*
|
||||||
|
* @param[in] node The node that we received the request from
|
||||||
* @param[in] peer The peer that we received the request from
|
* @param[in] peer The peer that we received the request from
|
||||||
* @param[in] vRecv The raw message received
|
* @param[in] vRecv The raw message received
|
||||||
*/
|
*/
|
||||||
void ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv);
|
void ProcessGetCFHeaders(CNode& node, Peer& peer, CDataStream& vRecv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a getcfcheckpt request.
|
* Handle a getcfcheckpt request.
|
||||||
*
|
*
|
||||||
* May disconnect from the peer in the case of a bad request.
|
* May disconnect from the peer in the case of a bad request.
|
||||||
*
|
*
|
||||||
|
* @param[in] node The node that we received the request from
|
||||||
* @param[in] peer The peer that we received the request from
|
* @param[in] peer The peer that we received the request from
|
||||||
* @param[in] vRecv The raw message received
|
* @param[in] vRecv The raw message received
|
||||||
*/
|
*/
|
||||||
void ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv);
|
void ProcessGetCFCheckPt(CNode& node, Peer& peer, CDataStream& vRecv);
|
||||||
|
|
||||||
/** Checks if address relay is permitted with peer. If needed, initializes
|
/** Checks if address relay is permitted with peer. If needed, initializes
|
||||||
* the m_addr_known bloom filter and sets m_addr_relay_enabled to true.
|
* the m_addr_known bloom filter and sets m_addr_relay_enabled to true.
|
||||||
|
@ -1278,10 +1280,7 @@ void PeerManagerImpl::FindNextBlocksToDownload(const Peer& peer, unsigned int co
|
||||||
|
|
||||||
void PeerManagerImpl::PushNodeVersion(CNode& pnode, const Peer& peer)
|
void PeerManagerImpl::PushNodeVersion(CNode& pnode, const Peer& peer)
|
||||||
{
|
{
|
||||||
// Note that pnode->GetLocalServices() is a reflection of the local
|
uint64_t my_services{peer.m_our_services};
|
||||||
// services we were offering when the CNode object was created for this
|
|
||||||
// peer.
|
|
||||||
uint64_t my_services{pnode.GetLocalServices()};
|
|
||||||
const int64_t nTime{count_seconds(GetTime<std::chrono::seconds>())};
|
const int64_t nTime{count_seconds(GetTime<std::chrono::seconds>())};
|
||||||
uint64_t nonce = pnode.GetLocalNonce();
|
uint64_t nonce = pnode.GetLocalNonce();
|
||||||
const int nNodeStartingHeight{m_best_height};
|
const int nNodeStartingHeight{m_best_height};
|
||||||
|
@ -2016,7 +2015,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
||||||
}
|
}
|
||||||
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
|
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
|
||||||
if (!pfrom.HasPermission(NetPermissionFlags::NoBan) && (
|
if (!pfrom.HasPermission(NetPermissionFlags::NoBan) && (
|
||||||
(((pfrom.GetLocalServices() & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((pfrom.GetLocalServices() & NODE_NETWORK) != NODE_NETWORK) && (m_chainman.ActiveChain().Tip()->nHeight - pindex->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */) )
|
(((peer.m_our_services & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((peer.m_our_services & NODE_NETWORK) != NODE_NETWORK) && (m_chainman.ActiveChain().Tip()->nHeight - pindex->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */) )
|
||||||
)) {
|
)) {
|
||||||
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n", pfrom.GetId());
|
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n", pfrom.GetId());
|
||||||
//disconnect node and prevent it from stalling (would otherwise wait for the missing block)
|
//disconnect node and prevent it from stalling (would otherwise wait for the missing block)
|
||||||
|
@ -2597,7 +2596,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
|
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& node, Peer& peer,
|
||||||
BlockFilterType filter_type, uint32_t start_height,
|
BlockFilterType filter_type, uint32_t start_height,
|
||||||
const uint256& stop_hash, uint32_t max_height_diff,
|
const uint256& stop_hash, uint32_t max_height_diff,
|
||||||
const CBlockIndex*& stop_index,
|
const CBlockIndex*& stop_index,
|
||||||
|
@ -2605,11 +2604,11 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
|
||||||
{
|
{
|
||||||
const bool supported_filter_type =
|
const bool supported_filter_type =
|
||||||
(filter_type == BlockFilterType::BASIC &&
|
(filter_type == BlockFilterType::BASIC &&
|
||||||
(peer.GetLocalServices() & NODE_COMPACT_FILTERS));
|
(peer.m_our_services & NODE_COMPACT_FILTERS));
|
||||||
if (!supported_filter_type) {
|
if (!supported_filter_type) {
|
||||||
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
|
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
|
||||||
peer.GetId(), static_cast<uint8_t>(filter_type));
|
node.GetId(), static_cast<uint8_t>(filter_type));
|
||||||
peer.fDisconnect = true;
|
node.fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2620,8 +2619,8 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
|
||||||
// Check that the stop block exists and the peer would be allowed to fetch it.
|
// Check that the stop block exists and the peer would be allowed to fetch it.
|
||||||
if (!stop_index || !BlockRequestAllowed(stop_index)) {
|
if (!stop_index || !BlockRequestAllowed(stop_index)) {
|
||||||
LogPrint(BCLog::NET, "peer %d requested invalid block hash: %s\n",
|
LogPrint(BCLog::NET, "peer %d requested invalid block hash: %s\n",
|
||||||
peer.GetId(), stop_hash.ToString());
|
node.GetId(), stop_hash.ToString());
|
||||||
peer.fDisconnect = true;
|
node.fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2630,14 +2629,14 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
|
||||||
if (start_height > stop_height) {
|
if (start_height > stop_height) {
|
||||||
LogPrint(BCLog::NET, "peer %d sent invalid getcfilters/getcfheaders with " /* Continued */
|
LogPrint(BCLog::NET, "peer %d sent invalid getcfilters/getcfheaders with " /* Continued */
|
||||||
"start height %d and stop height %d\n",
|
"start height %d and stop height %d\n",
|
||||||
peer.GetId(), start_height, stop_height);
|
node.GetId(), start_height, stop_height);
|
||||||
peer.fDisconnect = true;
|
node.fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (stop_height - start_height >= max_height_diff) {
|
if (stop_height - start_height >= max_height_diff) {
|
||||||
LogPrint(BCLog::NET, "peer %d requested too many cfilters/cfheaders: %d / %d\n",
|
LogPrint(BCLog::NET, "peer %d requested too many cfilters/cfheaders: %d / %d\n",
|
||||||
peer.GetId(), stop_height - start_height + 1, max_height_diff);
|
node.GetId(), stop_height - start_height + 1, max_height_diff);
|
||||||
peer.fDisconnect = true;
|
node.fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2650,7 +2649,7 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
|
void PeerManagerImpl::ProcessGetCFilters(CNode& node,Peer& peer, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
uint8_t filter_type_ser;
|
uint8_t filter_type_ser;
|
||||||
uint32_t start_height;
|
uint32_t start_height;
|
||||||
|
@ -2662,7 +2661,7 @@ void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
|
||||||
|
|
||||||
const CBlockIndex* stop_index;
|
const CBlockIndex* stop_index;
|
||||||
BlockFilterIndex* filter_index;
|
BlockFilterIndex* filter_index;
|
||||||
if (!PrepareBlockFilterRequest(peer, filter_type, start_height, stop_hash,
|
if (!PrepareBlockFilterRequest(node, peer, filter_type, start_height, stop_hash,
|
||||||
MAX_GETCFILTERS_SIZE, stop_index, filter_index)) {
|
MAX_GETCFILTERS_SIZE, stop_index, filter_index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2675,13 +2674,13 @@ void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& filter : filters) {
|
for (const auto& filter : filters) {
|
||||||
CSerializedNetMsg msg = CNetMsgMaker(peer.GetCommonVersion())
|
CSerializedNetMsg msg = CNetMsgMaker(node.GetCommonVersion())
|
||||||
.Make(NetMsgType::CFILTER, filter);
|
.Make(NetMsgType::CFILTER, filter);
|
||||||
m_connman.PushMessage(&peer, std::move(msg));
|
m_connman.PushMessage(&node, std::move(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
|
void PeerManagerImpl::ProcessGetCFHeaders(CNode& node, Peer& peer, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
uint8_t filter_type_ser;
|
uint8_t filter_type_ser;
|
||||||
uint32_t start_height;
|
uint32_t start_height;
|
||||||
|
@ -2693,7 +2692,7 @@ void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
|
||||||
|
|
||||||
const CBlockIndex* stop_index;
|
const CBlockIndex* stop_index;
|
||||||
BlockFilterIndex* filter_index;
|
BlockFilterIndex* filter_index;
|
||||||
if (!PrepareBlockFilterRequest(peer, filter_type, start_height, stop_hash,
|
if (!PrepareBlockFilterRequest(node, peer, filter_type, start_height, stop_hash,
|
||||||
MAX_GETCFHEADERS_SIZE, stop_index, filter_index)) {
|
MAX_GETCFHEADERS_SIZE, stop_index, filter_index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2716,16 +2715,16 @@ void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSerializedNetMsg msg = CNetMsgMaker(peer.GetCommonVersion())
|
CSerializedNetMsg msg = CNetMsgMaker(node.GetCommonVersion())
|
||||||
.Make(NetMsgType::CFHEADERS,
|
.Make(NetMsgType::CFHEADERS,
|
||||||
filter_type_ser,
|
filter_type_ser,
|
||||||
stop_index->GetBlockHash(),
|
stop_index->GetBlockHash(),
|
||||||
prev_header,
|
prev_header,
|
||||||
filter_hashes);
|
filter_hashes);
|
||||||
m_connman.PushMessage(&peer, std::move(msg));
|
m_connman.PushMessage(&node, std::move(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv)
|
void PeerManagerImpl::ProcessGetCFCheckPt(CNode& node, Peer& peer, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
uint8_t filter_type_ser;
|
uint8_t filter_type_ser;
|
||||||
uint256 stop_hash;
|
uint256 stop_hash;
|
||||||
|
@ -2736,7 +2735,7 @@ void PeerManagerImpl::ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv)
|
||||||
|
|
||||||
const CBlockIndex* stop_index;
|
const CBlockIndex* stop_index;
|
||||||
BlockFilterIndex* filter_index;
|
BlockFilterIndex* filter_index;
|
||||||
if (!PrepareBlockFilterRequest(peer, filter_type, /*start_height=*/0, stop_hash,
|
if (!PrepareBlockFilterRequest(node, peer, filter_type, /*start_height=*/0, stop_hash,
|
||||||
/*max_height_diff=*/std::numeric_limits<uint32_t>::max(),
|
/*max_height_diff=*/std::numeric_limits<uint32_t>::max(),
|
||||||
stop_index, filter_index)) {
|
stop_index, filter_index)) {
|
||||||
return;
|
return;
|
||||||
|
@ -2757,12 +2756,12 @@ void PeerManagerImpl::ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSerializedNetMsg msg = CNetMsgMaker(peer.GetCommonVersion())
|
CSerializedNetMsg msg = CNetMsgMaker(node.GetCommonVersion())
|
||||||
.Make(NetMsgType::CFCHECKPT,
|
.Make(NetMsgType::CFCHECKPT,
|
||||||
filter_type_ser,
|
filter_type_ser,
|
||||||
stop_index->GetBlockHash(),
|
stop_index->GetBlockHash(),
|
||||||
headers);
|
headers);
|
||||||
m_connman.PushMessage(&peer, std::move(msg));
|
m_connman.PushMessage(&node, std::move(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing)
|
void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing)
|
||||||
|
@ -2898,7 +2897,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
// - fRelay=true or we're offering NODE_BLOOM to this peer
|
// - fRelay=true or we're offering NODE_BLOOM to this peer
|
||||||
// (NODE_BLOOM means that the peer may turn on tx relay later)
|
// (NODE_BLOOM means that the peer may turn on tx relay later)
|
||||||
if (!pfrom.IsBlockOnlyConn() &&
|
if (!pfrom.IsBlockOnlyConn() &&
|
||||||
(fRelay || (pfrom.GetLocalServices() & NODE_BLOOM))) {
|
(fRelay || (peer->m_our_services & NODE_BLOOM))) {
|
||||||
auto* const tx_relay = peer->SetTxRelay();
|
auto* const tx_relay = peer->SetTxRelay();
|
||||||
{
|
{
|
||||||
LOCK(tx_relay->m_bloom_filter_mutex);
|
LOCK(tx_relay->m_bloom_filter_mutex);
|
||||||
|
@ -4092,7 +4091,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::MEMPOOL) {
|
if (msg_type == NetMsgType::MEMPOOL) {
|
||||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM) && !pfrom.HasPermission(NetPermissionFlags::Mempool))
|
if (!(peer->m_our_services & NODE_BLOOM) && !pfrom.HasPermission(NetPermissionFlags::Mempool))
|
||||||
{
|
{
|
||||||
if (!pfrom.HasPermission(NetPermissionFlags::NoBan))
|
if (!pfrom.HasPermission(NetPermissionFlags::NoBan))
|
||||||
{
|
{
|
||||||
|
@ -4195,7 +4194,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::FILTERLOAD) {
|
if (msg_type == NetMsgType::FILTERLOAD) {
|
||||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
if (!(peer->m_our_services & NODE_BLOOM)) {
|
||||||
LogPrint(BCLog::NET, "filterload received despite not offering bloom services from peer=%d; disconnecting\n", pfrom.GetId());
|
LogPrint(BCLog::NET, "filterload received despite not offering bloom services from peer=%d; disconnecting\n", pfrom.GetId());
|
||||||
pfrom.fDisconnect = true;
|
pfrom.fDisconnect = true;
|
||||||
return;
|
return;
|
||||||
|
@ -4220,7 +4219,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::FILTERADD) {
|
if (msg_type == NetMsgType::FILTERADD) {
|
||||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
if (!(peer->m_our_services & NODE_BLOOM)) {
|
||||||
LogPrint(BCLog::NET, "filteradd received despite not offering bloom services from peer=%d; disconnecting\n", pfrom.GetId());
|
LogPrint(BCLog::NET, "filteradd received despite not offering bloom services from peer=%d; disconnecting\n", pfrom.GetId());
|
||||||
pfrom.fDisconnect = true;
|
pfrom.fDisconnect = true;
|
||||||
return;
|
return;
|
||||||
|
@ -4248,7 +4247,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::FILTERCLEAR) {
|
if (msg_type == NetMsgType::FILTERCLEAR) {
|
||||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
if (!(peer->m_our_services & NODE_BLOOM)) {
|
||||||
LogPrint(BCLog::NET, "filterclear received despite not offering bloom services from peer=%d; disconnecting\n", pfrom.GetId());
|
LogPrint(BCLog::NET, "filterclear received despite not offering bloom services from peer=%d; disconnecting\n", pfrom.GetId());
|
||||||
pfrom.fDisconnect = true;
|
pfrom.fDisconnect = true;
|
||||||
return;
|
return;
|
||||||
|
@ -4279,17 +4278,17 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::GETCFILTERS) {
|
if (msg_type == NetMsgType::GETCFILTERS) {
|
||||||
ProcessGetCFilters(pfrom, vRecv);
|
ProcessGetCFilters(pfrom, *peer, vRecv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::GETCFHEADERS) {
|
if (msg_type == NetMsgType::GETCFHEADERS) {
|
||||||
ProcessGetCFHeaders(pfrom, vRecv);
|
ProcessGetCFHeaders(pfrom, *peer, vRecv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::GETCFCHECKPT) {
|
if (msg_type == NetMsgType::GETCFCHECKPT) {
|
||||||
ProcessGetCFCheckPt(pfrom, vRecv);
|
ProcessGetCFCheckPt(pfrom, *peer, vRecv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
|
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
|
||||||
NodeId id{0};
|
NodeId id{0};
|
||||||
CNode dummyNode1{id++,
|
CNode dummyNode1{id++,
|
||||||
ServiceFlags(NODE_NETWORK | NODE_WITNESS),
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr1,
|
addr1,
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -68,6 +67,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||||
/*node=*/dummyNode1,
|
/*node=*/dummyNode1,
|
||||||
/*successfully_connected=*/true,
|
/*successfully_connected=*/true,
|
||||||
/*remote_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS),
|
/*remote_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS),
|
||||||
|
/*local_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS),
|
||||||
/*permission_flags=*/NetPermissionFlags::None,
|
/*permission_flags=*/NetPermissionFlags::None,
|
||||||
/*version=*/PROTOCOL_VERSION,
|
/*version=*/PROTOCOL_VERSION,
|
||||||
/*relay_txs=*/true);
|
/*relay_txs=*/true);
|
||||||
|
@ -117,7 +117,6 @@ static void AddRandomOutboundPeer(NodeId& id, std::vector<CNode*>& vNodes, PeerM
|
||||||
{
|
{
|
||||||
CAddress addr(ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE);
|
CAddress addr(ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE);
|
||||||
vNodes.emplace_back(new CNode{id++,
|
vNodes.emplace_back(new CNode{id++,
|
||||||
ServiceFlags(NODE_NETWORK | NODE_WITNESS),
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -129,7 +128,7 @@ static void AddRandomOutboundPeer(NodeId& id, std::vector<CNode*>& vNodes, PeerM
|
||||||
CNode &node = *vNodes.back();
|
CNode &node = *vNodes.back();
|
||||||
node.SetCommonVersion(PROTOCOL_VERSION);
|
node.SetCommonVersion(PROTOCOL_VERSION);
|
||||||
|
|
||||||
peerLogic.InitializeNode(node, node.GetLocalServices());
|
peerLogic.InitializeNode(node, ServiceFlags(NODE_NETWORK | NODE_WITNESS));
|
||||||
node.fSuccessfullyConnected = true;
|
node.fSuccessfullyConnected = true;
|
||||||
|
|
||||||
connman.AddTestNode(node);
|
connman.AddTestNode(node);
|
||||||
|
@ -297,7 +296,6 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
banman->ClearBanned();
|
banman->ClearBanned();
|
||||||
NodeId id{0};
|
NodeId id{0};
|
||||||
nodes[0] = new CNode{id++,
|
nodes[0] = new CNode{id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr[0],
|
addr[0],
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -307,7 +305,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
ConnectionType::INBOUND,
|
ConnectionType::INBOUND,
|
||||||
/*inbound_onion=*/false};
|
/*inbound_onion=*/false};
|
||||||
nodes[0]->SetCommonVersion(PROTOCOL_VERSION);
|
nodes[0]->SetCommonVersion(PROTOCOL_VERSION);
|
||||||
peerLogic->InitializeNode(*nodes[0], nodes[0]->GetLocalServices());
|
peerLogic->InitializeNode(*nodes[0], NODE_NETWORK);
|
||||||
nodes[0]->fSuccessfullyConnected = true;
|
nodes[0]->fSuccessfullyConnected = true;
|
||||||
connman->AddTestNode(*nodes[0]);
|
connman->AddTestNode(*nodes[0]);
|
||||||
peerLogic->UnitTestMisbehaving(nodes[0]->GetId(), DISCOURAGEMENT_THRESHOLD); // Should be discouraged
|
peerLogic->UnitTestMisbehaving(nodes[0]->GetId(), DISCOURAGEMENT_THRESHOLD); // Should be discouraged
|
||||||
|
@ -320,7 +318,6 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
BOOST_CHECK(!banman->IsDiscouraged(other_addr)); // Different address, not discouraged
|
BOOST_CHECK(!banman->IsDiscouraged(other_addr)); // Different address, not discouraged
|
||||||
|
|
||||||
nodes[1] = new CNode{id++,
|
nodes[1] = new CNode{id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr[1],
|
addr[1],
|
||||||
/*nKeyedNetGroupIn=*/1,
|
/*nKeyedNetGroupIn=*/1,
|
||||||
|
@ -330,7 +327,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
ConnectionType::INBOUND,
|
ConnectionType::INBOUND,
|
||||||
/*inbound_onion=*/false};
|
/*inbound_onion=*/false};
|
||||||
nodes[1]->SetCommonVersion(PROTOCOL_VERSION);
|
nodes[1]->SetCommonVersion(PROTOCOL_VERSION);
|
||||||
peerLogic->InitializeNode(*nodes[1], nodes[1]->GetLocalServices());
|
peerLogic->InitializeNode(*nodes[1], NODE_NETWORK);
|
||||||
nodes[1]->fSuccessfullyConnected = true;
|
nodes[1]->fSuccessfullyConnected = true;
|
||||||
connman->AddTestNode(*nodes[1]);
|
connman->AddTestNode(*nodes[1]);
|
||||||
peerLogic->UnitTestMisbehaving(nodes[1]->GetId(), DISCOURAGEMENT_THRESHOLD - 1);
|
peerLogic->UnitTestMisbehaving(nodes[1]->GetId(), DISCOURAGEMENT_THRESHOLD - 1);
|
||||||
|
@ -358,7 +355,6 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
// Make sure non-IP peers are discouraged and disconnected properly.
|
// Make sure non-IP peers are discouraged and disconnected properly.
|
||||||
|
|
||||||
nodes[2] = new CNode{id++,
|
nodes[2] = new CNode{id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr[2],
|
addr[2],
|
||||||
/*nKeyedNetGroupIn=*/1,
|
/*nKeyedNetGroupIn=*/1,
|
||||||
|
@ -368,7 +364,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
ConnectionType::OUTBOUND_FULL_RELAY,
|
ConnectionType::OUTBOUND_FULL_RELAY,
|
||||||
/*inbound_onion=*/false};
|
/*inbound_onion=*/false};
|
||||||
nodes[2]->SetCommonVersion(PROTOCOL_VERSION);
|
nodes[2]->SetCommonVersion(PROTOCOL_VERSION);
|
||||||
peerLogic->InitializeNode(*nodes[2], nodes[2]->GetLocalServices());
|
peerLogic->InitializeNode(*nodes[2], NODE_NETWORK);
|
||||||
nodes[2]->fSuccessfullyConnected = true;
|
nodes[2]->fSuccessfullyConnected = true;
|
||||||
connman->AddTestNode(*nodes[2]);
|
connman->AddTestNode(*nodes[2]);
|
||||||
peerLogic->UnitTestMisbehaving(nodes[2]->GetId(), DISCOURAGEMENT_THRESHOLD);
|
peerLogic->UnitTestMisbehaving(nodes[2]->GetId(), DISCOURAGEMENT_THRESHOLD);
|
||||||
|
@ -403,7 +399,6 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
CAddress addr(ip(0xa0b0c001), NODE_NONE);
|
CAddress addr(ip(0xa0b0c001), NODE_NONE);
|
||||||
NodeId id{0};
|
NodeId id{0};
|
||||||
CNode dummyNode{id++,
|
CNode dummyNode{id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/4,
|
/*nKeyedNetGroupIn=*/4,
|
||||||
|
@ -413,7 +408,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
ConnectionType::INBOUND,
|
ConnectionType::INBOUND,
|
||||||
/*inbound_onion=*/false};
|
/*inbound_onion=*/false};
|
||||||
dummyNode.SetCommonVersion(PROTOCOL_VERSION);
|
dummyNode.SetCommonVersion(PROTOCOL_VERSION);
|
||||||
peerLogic->InitializeNode(dummyNode, dummyNode.GetLocalServices());
|
peerLogic->InitializeNode(dummyNode, NODE_NETWORK);
|
||||||
dummyNode.fSuccessfullyConnected = true;
|
dummyNode.fSuccessfullyConnected = true;
|
||||||
|
|
||||||
peerLogic->UnitTestMisbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD);
|
peerLogic->UnitTestMisbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD);
|
||||||
|
|
|
@ -68,7 +68,6 @@ FUZZ_TARGET_INIT(net, initialize_net)
|
||||||
(void)node.GetAddrLocal();
|
(void)node.GetAddrLocal();
|
||||||
(void)node.GetId();
|
(void)node.GetId();
|
||||||
(void)node.GetLocalNonce();
|
(void)node.GetLocalNonce();
|
||||||
(void)node.GetLocalServices();
|
|
||||||
const int ref_count = node.GetRefCount();
|
const int ref_count = node.GetRefCount();
|
||||||
assert(ref_count >= 0);
|
assert(ref_count >= 0);
|
||||||
(void)node.GetCommonVersion();
|
(void)node.GetCommonVersion();
|
||||||
|
|
|
@ -294,6 +294,7 @@ void FillNode(FuzzedDataProvider& fuzzed_data_provider, ConnmanTestMsg& connman,
|
||||||
connman.Handshake(node,
|
connman.Handshake(node,
|
||||||
/*successfully_connected=*/fuzzed_data_provider.ConsumeBool(),
|
/*successfully_connected=*/fuzzed_data_provider.ConsumeBool(),
|
||||||
/*remote_services=*/ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS),
|
/*remote_services=*/ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS),
|
||||||
|
/*local_services=*/ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS),
|
||||||
/*permission_flags=*/ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS),
|
/*permission_flags=*/ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS),
|
||||||
/*version=*/fuzzed_data_provider.ConsumeIntegralInRange<int32_t>(MIN_PEER_PROTO_VERSION, std::numeric_limits<int32_t>::max()),
|
/*version=*/fuzzed_data_provider.ConsumeIntegralInRange<int32_t>(MIN_PEER_PROTO_VERSION, std::numeric_limits<int32_t>::max()),
|
||||||
/*relay_txs=*/fuzzed_data_provider.ConsumeBool());
|
/*relay_txs=*/fuzzed_data_provider.ConsumeBool());
|
||||||
|
|
|
@ -296,7 +296,6 @@ template <bool ReturnUniquePtr = false>
|
||||||
auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<NodeId>& node_id_in = std::nullopt) noexcept
|
auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<NodeId>& node_id_in = std::nullopt) noexcept
|
||||||
{
|
{
|
||||||
const NodeId node_id = node_id_in.value_or(fuzzed_data_provider.ConsumeIntegralInRange<NodeId>(0, std::numeric_limits<NodeId>::max()));
|
const NodeId node_id = node_id_in.value_or(fuzzed_data_provider.ConsumeIntegralInRange<NodeId>(0, std::numeric_limits<NodeId>::max()));
|
||||||
const ServiceFlags local_services = ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS);
|
|
||||||
const auto sock = std::make_shared<FuzzedSock>(fuzzed_data_provider);
|
const auto sock = std::make_shared<FuzzedSock>(fuzzed_data_provider);
|
||||||
const CAddress address = ConsumeAddress(fuzzed_data_provider);
|
const CAddress address = ConsumeAddress(fuzzed_data_provider);
|
||||||
const uint64_t keyed_net_group = fuzzed_data_provider.ConsumeIntegral<uint64_t>();
|
const uint64_t keyed_net_group = fuzzed_data_provider.ConsumeIntegral<uint64_t>();
|
||||||
|
@ -307,7 +306,6 @@ auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<N
|
||||||
const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false};
|
const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false};
|
||||||
if constexpr (ReturnUniquePtr) {
|
if constexpr (ReturnUniquePtr) {
|
||||||
return std::make_unique<CNode>(node_id,
|
return std::make_unique<CNode>(node_id,
|
||||||
local_services,
|
|
||||||
sock,
|
sock,
|
||||||
address,
|
address,
|
||||||
keyed_net_group,
|
keyed_net_group,
|
||||||
|
@ -318,7 +316,6 @@ auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<N
|
||||||
inbound_onion);
|
inbound_onion);
|
||||||
} else {
|
} else {
|
||||||
return CNode{node_id,
|
return CNode{node_id,
|
||||||
local_services,
|
|
||||||
sock,
|
sock,
|
||||||
address,
|
address,
|
||||||
keyed_net_group,
|
keyed_net_group,
|
||||||
|
|
|
@ -58,7 +58,6 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
std::string pszDest;
|
std::string pszDest;
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode1 = std::make_unique<CNode>(id++,
|
std::unique_ptr<CNode> pnode1 = std::make_unique<CNode>(id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -77,7 +76,6 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
BOOST_CHECK_EQUAL(pnode1->ConnectedThroughNetwork(), Network::NET_IPV4);
|
BOOST_CHECK_EQUAL(pnode1->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode2 = std::make_unique<CNode>(id++,
|
std::unique_ptr<CNode> pnode2 = std::make_unique<CNode>(id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/1,
|
/*nKeyedNetGroupIn=*/1,
|
||||||
|
@ -96,7 +94,6 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
BOOST_CHECK_EQUAL(pnode2->ConnectedThroughNetwork(), Network::NET_IPV4);
|
BOOST_CHECK_EQUAL(pnode2->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode3 = std::make_unique<CNode>(id++,
|
std::unique_ptr<CNode> pnode3 = std::make_unique<CNode>(id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -115,7 +112,6 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||||
BOOST_CHECK_EQUAL(pnode3->ConnectedThroughNetwork(), Network::NET_IPV4);
|
BOOST_CHECK_EQUAL(pnode3->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||||
|
|
||||||
std::unique_ptr<CNode> pnode4 = std::make_unique<CNode>(id++,
|
std::unique_ptr<CNode> pnode4 = std::make_unique<CNode>(id++,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/1,
|
/*nKeyedNetGroupIn=*/1,
|
||||||
|
@ -629,7 +625,6 @@ BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test)
|
||||||
ipv4AddrPeer.s_addr = 0xa0b0c001;
|
ipv4AddrPeer.s_addr = 0xa0b0c001;
|
||||||
CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK);
|
CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK);
|
||||||
std::unique_ptr<CNode> pnode = std::make_unique<CNode>(/*id=*/0,
|
std::unique_ptr<CNode> pnode = std::make_unique<CNode>(/*id=*/0,
|
||||||
NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
addr,
|
addr,
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -684,7 +679,6 @@ BOOST_AUTO_TEST_CASE(get_local_addr_for_peer_port)
|
||||||
in_addr peer_out_in_addr;
|
in_addr peer_out_in_addr;
|
||||||
peer_out_in_addr.s_addr = htonl(0x01020304);
|
peer_out_in_addr.s_addr = htonl(0x01020304);
|
||||||
CNode peer_out{/*id=*/0,
|
CNode peer_out{/*id=*/0,
|
||||||
/*nLocalServicesIn=*/NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
/*addrIn=*/CAddress{CService{peer_out_in_addr, 8333}, NODE_NETWORK},
|
/*addrIn=*/CAddress{CService{peer_out_in_addr, 8333}, NODE_NETWORK},
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -706,7 +700,6 @@ BOOST_AUTO_TEST_CASE(get_local_addr_for_peer_port)
|
||||||
in_addr peer_in_in_addr;
|
in_addr peer_in_in_addr;
|
||||||
peer_in_in_addr.s_addr = htonl(0x05060708);
|
peer_in_in_addr.s_addr = htonl(0x05060708);
|
||||||
CNode peer_in{/*id=*/0,
|
CNode peer_in{/*id=*/0,
|
||||||
/*nLocalServicesIn=*/NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
/*addrIn=*/CAddress{CService{peer_in_in_addr, 8333}, NODE_NETWORK},
|
/*addrIn=*/CAddress{CService{peer_in_in_addr, 8333}, NODE_NETWORK},
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -834,7 +827,6 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
|
||||||
in_addr peer_in_addr;
|
in_addr peer_in_addr;
|
||||||
peer_in_addr.s_addr = htonl(0x01020304);
|
peer_in_addr.s_addr = htonl(0x01020304);
|
||||||
CNode peer{/*id=*/0,
|
CNode peer{/*id=*/0,
|
||||||
/*nLocalServicesIn=*/NODE_NETWORK,
|
|
||||||
/*sock=*/nullptr,
|
/*sock=*/nullptr,
|
||||||
/*addrIn=*/CAddress{CService{peer_in_addr, 8333}, NODE_NETWORK},
|
/*addrIn=*/CAddress{CService{peer_in_addr, 8333}, NODE_NETWORK},
|
||||||
/*nKeyedNetGroupIn=*/0,
|
/*nKeyedNetGroupIn=*/0,
|
||||||
|
@ -854,7 +846,7 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
|
||||||
*static_cast<TestChainState*>(&m_node.chainman->ActiveChainstate());
|
*static_cast<TestChainState*>(&m_node.chainman->ActiveChainstate());
|
||||||
chainstate.JumpOutOfIbd();
|
chainstate.JumpOutOfIbd();
|
||||||
|
|
||||||
m_node.peerman->InitializeNode(peer, peer.GetLocalServices());
|
m_node.peerman->InitializeNode(peer, NODE_NETWORK);
|
||||||
|
|
||||||
std::atomic<bool> interrupt_dummy{false};
|
std::atomic<bool> interrupt_dummy{false};
|
||||||
std::chrono::microseconds time_received_dummy{0};
|
std::chrono::microseconds time_received_dummy{0};
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
void ConnmanTestMsg::Handshake(CNode& node,
|
void ConnmanTestMsg::Handshake(CNode& node,
|
||||||
bool successfully_connected,
|
bool successfully_connected,
|
||||||
ServiceFlags remote_services,
|
ServiceFlags remote_services,
|
||||||
|
ServiceFlags local_services,
|
||||||
NetPermissionFlags permission_flags,
|
NetPermissionFlags permission_flags,
|
||||||
int32_t version,
|
int32_t version,
|
||||||
bool relay_txs)
|
bool relay_txs)
|
||||||
|
@ -24,7 +25,7 @@ void ConnmanTestMsg::Handshake(CNode& node,
|
||||||
auto& connman{*this};
|
auto& connman{*this};
|
||||||
const CNetMsgMaker mm{0};
|
const CNetMsgMaker mm{0};
|
||||||
|
|
||||||
peerman.InitializeNode(node, node.GetLocalServices());
|
peerman.InitializeNode(node, local_services);
|
||||||
|
|
||||||
CSerializedNetMsg msg_version{
|
CSerializedNetMsg msg_version{
|
||||||
mm.Make(NetMsgType::VERSION,
|
mm.Make(NetMsgType::VERSION,
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct ConnmanTestMsg : public CConnman {
|
||||||
void Handshake(CNode& node,
|
void Handshake(CNode& node,
|
||||||
bool successfully_connected,
|
bool successfully_connected,
|
||||||
ServiceFlags remote_services,
|
ServiceFlags remote_services,
|
||||||
|
ServiceFlags local_services,
|
||||||
NetPermissionFlags permission_flags,
|
NetPermissionFlags permission_flags,
|
||||||
int32_t version,
|
int32_t version,
|
||||||
bool relay_txs);
|
bool relay_txs);
|
||||||
|
|
Loading…
Add table
Reference in a new issue