@@ -573,7 +573,10 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
573
573
pszDest ? pszDest : " " ,
574
574
conn_type,
575
575
/* inbound_onion=*/ false ,
576
- CNodeOptions{ .i2p_sam_session = std::move (i2p_transient_session) });
576
+ CNodeOptions{
577
+ .i2p_sam_session = std::move (i2p_transient_session),
578
+ .recv_flood_size = nReceiveFloodSize,
579
+ });
577
580
pnode->AddRef ();
578
581
579
582
// We're making a new connection, harvest entropy from the time (and our peer count)
@@ -917,7 +920,7 @@ bool CConnman::AttemptToEvictConnection()
917
920
.m_is_local = node->addr .IsLocal (),
918
921
.m_network = node->ConnectedThroughNetwork (),
919
922
.m_noban = node->HasPermission (NetPermissionFlags::NoBan),
920
- .m_conn_type = node->GetConnectionType () ,
923
+ .m_conn_type = node->m_conn_type ,
921
924
};
922
925
vEvictionCandidates.push_back (candidate);
923
926
}
@@ -1051,8 +1054,9 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
1051
1054
ConnectionType::INBOUND,
1052
1055
inbound_onion,
1053
1056
CNodeOptions{
1054
- .permission_flags = permission_flags,
1055
- .prefer_evict = discouraged,
1057
+ .permission_flags = permission_flags,
1058
+ .prefer_evict = discouraged,
1059
+ .recv_flood_size = nReceiveFloodSize,
1056
1060
});
1057
1061
pnode->AddRef ();
1058
1062
m_msgproc->InitializeNode (*pnode, nodeServices);
@@ -1092,7 +1096,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
1092
1096
1093
1097
// Count existing connections
1094
1098
int existing_connections = WITH_LOCK (m_nodes_mutex,
1095
- return std::count_if (m_nodes.begin (), m_nodes.end (), [conn_type](CNode* node) { return node->GetConnectionType () == conn_type; }););
1099
+ return std::count_if (m_nodes.begin (), m_nodes.end (), [conn_type](CNode* node) { return node->m_conn_type == conn_type; }););
1096
1100
1097
1101
// Max connections of specified type already exist
1098
1102
if (max_connections != std::nullopt && existing_connections >= max_connections) return false ;
@@ -1328,7 +1332,7 @@ void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes,
1328
1332
}
1329
1333
RecordBytesRecv (nBytes);
1330
1334
if (notify) {
1331
- pnode->MarkReceivedMsgsForProcessing (nReceiveFloodSize );
1335
+ pnode->MarkReceivedMsgsForProcessing ();
1332
1336
WakeMessageHandler ();
1333
1337
}
1334
1338
}
@@ -1711,7 +1715,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
1711
1715
if (pnode->IsBlockOnlyConn ()) nOutboundBlockRelay++;
1712
1716
1713
1717
// Make sure our persistent outbound slots belong to different netgroups.
1714
- switch (pnode->GetConnectionType () ) {
1718
+ switch (pnode->m_conn_type ) {
1715
1719
// We currently don't take inbound connections into account. Since they are
1716
1720
// free to make, an attacker could make them to prevent us from connecting to
1717
1721
// certain peers.
@@ -2754,8 +2758,6 @@ ServiceFlags CConnman::GetLocalServices() const
2754
2758
return nLocalServices;
2755
2759
}
2756
2760
2757
- unsigned int CConnman::GetReceiveFloodSize () const { return nReceiveFloodSize; }
2758
-
2759
2761
CNode::CNode (NodeId idIn,
2760
2762
std::shared_ptr<Sock> sock,
2761
2763
const CAddress& addrIn,
@@ -2777,9 +2779,10 @@ CNode::CNode(NodeId idIn,
2777
2779
m_inbound_onion{inbound_onion},
2778
2780
m_prefer_evict{node_opts.prefer_evict },
2779
2781
nKeyedNetGroup{nKeyedNetGroupIn},
2782
+ m_conn_type{conn_type_in},
2780
2783
id{idIn},
2781
2784
nLocalHostNonce{nLocalHostNonceIn},
2782
- m_conn_type{conn_type_in },
2785
+ m_recv_flood_size{node_opts. recv_flood_size },
2783
2786
m_i2p_sam_session{std::move (node_opts.i2p_sam_session )}
2784
2787
{
2785
2788
if (inbound_onion) assert (conn_type_in == ConnectionType::INBOUND);
@@ -2795,7 +2798,7 @@ CNode::CNode(NodeId idIn,
2795
2798
}
2796
2799
}
2797
2800
2798
- void CNode::MarkReceivedMsgsForProcessing (unsigned int recv_flood_size )
2801
+ void CNode::MarkReceivedMsgsForProcessing ()
2799
2802
{
2800
2803
AssertLockNotHeld (m_msg_process_queue_mutex);
2801
2804
@@ -2809,10 +2812,10 @@ void CNode::MarkReceivedMsgsForProcessing(unsigned int recv_flood_size)
2809
2812
LOCK (m_msg_process_queue_mutex);
2810
2813
m_msg_process_queue.splice (m_msg_process_queue.end (), vRecvMsg);
2811
2814
m_msg_process_queue_size += nSizeAdded;
2812
- fPauseRecv = m_msg_process_queue_size > recv_flood_size ;
2815
+ fPauseRecv = m_msg_process_queue_size > m_recv_flood_size ;
2813
2816
}
2814
2817
2815
- std::optional<std::pair<CNetMessage, bool >> CNode::PollMessage (size_t recv_flood_size )
2818
+ std::optional<std::pair<CNetMessage, bool >> CNode::PollMessage ()
2816
2819
{
2817
2820
LOCK (m_msg_process_queue_mutex);
2818
2821
if (m_msg_process_queue.empty ()) return std::nullopt;
@@ -2821,7 +2824,7 @@ std::optional<std::pair<CNetMessage, bool>> CNode::PollMessage(size_t recv_flood
2821
2824
// Just take one message
2822
2825
msgs.splice (msgs.begin (), m_msg_process_queue, m_msg_process_queue.begin ());
2823
2826
m_msg_process_queue_size -= msgs.front ().m_raw_message_size ;
2824
- fPauseRecv = m_msg_process_queue_size > recv_flood_size ;
2827
+ fPauseRecv = m_msg_process_queue_size > m_recv_flood_size ;
2825
2828
2826
2829
return std::make_pair (std::move (msgs.front ()), !m_msg_process_queue.empty ());
2827
2830
}
0 commit comments