@@ -368,7 +368,7 @@ static CAddress GetBindAddress(SOCKET sock)
368
368
return addr_bind;
369
369
}
370
370
371
- CNode* CConnman::ConnectNode (CAddress addrConnect, const char *pszDest, bool fCountFailure , ConnectionType conn_type, bool block_relay_only )
371
+ CNode* CConnman::ConnectNode (CAddress addrConnect, const char *pszDest, bool fCountFailure , ConnectionType conn_type)
372
372
{
373
373
assert (conn_type != ConnectionType::INBOUND);
374
374
@@ -461,7 +461,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
461
461
NodeId id = GetNewNodeId ();
462
462
uint64_t nonce = GetDeterministicRandomizer (RANDOMIZER_ID_LOCALHOSTNONCE).Write (id).Finalize ();
463
463
CAddress addr_bind = GetBindAddress (hSocket);
464
- CNode* pnode = new CNode (id, nLocalServices, GetBestHeight (), hSocket, addrConnect, CalculateKeyedNetGroup (addrConnect), nonce, addr_bind, pszDest ? pszDest : " " , conn_type, block_relay_only );
464
+ CNode* pnode = new CNode (id, nLocalServices, GetBestHeight (), hSocket, addrConnect, CalculateKeyedNetGroup (addrConnect), nonce, addr_bind, pszDest ? pszDest : " " , conn_type);
465
465
pnode->AddRef ();
466
466
467
467
// We're making a new connection, harvest entropy from the time (and our peer count)
@@ -1938,13 +1938,17 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
1938
1938
1939
1939
// Open this connection as block-relay-only if we're already at our
1940
1940
// full-relay capacity, but not yet at our block-relay peer limit.
1941
- // (It should not be possible for fFeeler to be set if we're not
1942
- // also at our block-relay peer limit, but check against that as
1943
- // well for sanity.)
1944
- bool block_relay_only = nOutboundBlockRelay < m_max_outbound_block_relay && !fFeeler && nOutboundFullRelay >= m_max_outbound_full_relay;
1941
+ bool block_relay_only = nOutboundBlockRelay < m_max_outbound_block_relay && nOutboundFullRelay >= m_max_outbound_full_relay;
1942
+ ConnectionType conn_type;
1943
+ if (fFeeler ) {
1944
+ conn_type = ConnectionType::FEELER;
1945
+ } else if (block_relay_only) {
1946
+ conn_type = ConnectionType::BLOCK_RELAY;
1947
+ } else {
1948
+ conn_type = ConnectionType::OUTBOUND;
1949
+ }
1945
1950
1946
- ConnectionType conn_type = (fFeeler ? ConnectionType::FEELER : ConnectionType::OUTBOUND);
1947
- OpenNetworkConnection (addrConnect, (int )setConnected.size () >= std::min (nMaxConnections - 1 , 2 ), &grant, nullptr , false , conn_type, block_relay_only);
1951
+ OpenNetworkConnection (addrConnect, (int )setConnected.size () >= std::min (nMaxConnections - 1 , 2 ), &grant, nullptr , false , conn_type);
1948
1952
}
1949
1953
}
1950
1954
}
@@ -2031,7 +2035,7 @@ void CConnman::ThreadOpenAddedConnections()
2031
2035
}
2032
2036
2033
2037
// if successful, this moves the passed grant to the constructed node
2034
- void CConnman::OpenNetworkConnection (const CAddress& addrConnect, bool fCountFailure , CSemaphoreGrant *grantOutbound, const char *pszDest, bool m_addr_fetch, ConnectionType conn_type, bool block_relay_only )
2038
+ void CConnman::OpenNetworkConnection (const CAddress& addrConnect, bool fCountFailure , CSemaphoreGrant *grantOutbound, const char *pszDest, bool m_addr_fetch, ConnectionType conn_type)
2035
2039
{
2036
2040
assert (conn_type != ConnectionType::INBOUND);
2037
2041
@@ -2052,7 +2056,7 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
2052
2056
} else if (FindNode (std::string (pszDest)))
2053
2057
return ;
2054
2058
2055
- CNode* pnode = ConnectNode (addrConnect, pszDest, fCountFailure , conn_type, block_relay_only );
2059
+ CNode* pnode = ConnectNode (addrConnect, pszDest, fCountFailure , conn_type);
2056
2060
2057
2061
if (!pnode)
2058
2062
return ;
@@ -2733,7 +2737,7 @@ int CConnman::GetBestHeight() const
2733
2737
2734
2738
unsigned int CConnman::GetReceiveFloodSize () const { return nReceiveFloodSize; }
2735
2739
2736
- CNode::CNode (NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool block_relay_only )
2740
+ CNode::CNode (NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in)
2737
2741
: nTimeConnected(GetSystemTimeInSeconds()),
2738
2742
addr(addrIn),
2739
2743
addrBind(addrBindIn),
@@ -2744,7 +2748,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
2744
2748
// Don't relay addr messages to peers that we connect to as block-relay-only
2745
2749
// peers (to prevent adversaries from inferring these links from addr
2746
2750
// traffic).
2747
- m_addr_known{block_relay_only ? nullptr : MakeUnique<CRollingBloomFilter>(5000 , 0.001 )},
2751
+ m_addr_known{conn_type_in == ConnectionType::BLOCK_RELAY ? nullptr : MakeUnique<CRollingBloomFilter>(5000 , 0.001 )},
2748
2752
id (idIn),
2749
2753
nLocalHostNonce(nLocalHostNonceIn),
2750
2754
nLocalServices(nLocalServicesIn),
@@ -2753,7 +2757,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
2753
2757
hSocket = hSocketIn;
2754
2758
addrName = addrNameIn == " " ? addr.ToStringIPPort () : addrNameIn;
2755
2759
hashContinue = uint256 ();
2756
- if (!block_relay_only ) {
2760
+ if (conn_type_in != ConnectionType::BLOCK_RELAY ) {
2757
2761
m_tx_relay = MakeUnique<TxRelay>();
2758
2762
}
2759
2763
0 commit comments