aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authordergoegge <n.goeggi@gmail.com>2023-03-24 15:45:50 +0100
committerdergoegge <n.goeggi@gmail.com>2023-03-27 16:00:02 +0200
commitcd0c8eeb0940790b6ba83786d1c9e362d4dc4829 (patch)
tree6afc0ba7f9602b332307f952a0ee8f5875613d12 /src/net.cpp
parent860402ef2ed728ef096dda4e65e77d566782209f (diff)
[net] Pass nRecvFloodSize to CNode
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/net.cpp b/src/net.cpp
index f5d2328a0c..7023cb0f49 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -573,7 +573,10 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
pszDest ? pszDest : "",
conn_type,
/*inbound_onion=*/false,
- CNodeOptions{ .i2p_sam_session = std::move(i2p_transient_session) });
+ CNodeOptions{
+ .i2p_sam_session = std::move(i2p_transient_session),
+ .recv_flood_size = nReceiveFloodSize,
+ });
pnode->AddRef();
// We're making a new connection, harvest entropy from the time (and our peer count)
@@ -1051,8 +1054,9 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
ConnectionType::INBOUND,
inbound_onion,
CNodeOptions{
- .permission_flags = permission_flags,
- .prefer_evict = discouraged,
+ .permission_flags = permission_flags,
+ .prefer_evict = discouraged,
+ .recv_flood_size = nReceiveFloodSize,
});
pnode->AddRef();
m_msgproc->InitializeNode(*pnode, nodeServices);
@@ -1328,7 +1332,7 @@ void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes,
}
RecordBytesRecv(nBytes);
if (notify) {
- pnode->MarkReceivedMsgsForProcessing(nReceiveFloodSize);
+ pnode->MarkReceivedMsgsForProcessing();
WakeMessageHandler();
}
}
@@ -2754,8 +2758,6 @@ ServiceFlags CConnman::GetLocalServices() const
return nLocalServices;
}
-unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
-
CNode::CNode(NodeId idIn,
std::shared_ptr<Sock> sock,
const CAddress& addrIn,
@@ -2780,6 +2782,7 @@ CNode::CNode(NodeId idIn,
m_conn_type{conn_type_in},
id{idIn},
nLocalHostNonce{nLocalHostNonceIn},
+ m_recv_flood_size{node_opts.recv_flood_size},
m_i2p_sam_session{std::move(node_opts.i2p_sam_session)}
{
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
@@ -2795,7 +2798,7 @@ CNode::CNode(NodeId idIn,
}
}
-void CNode::MarkReceivedMsgsForProcessing(unsigned int recv_flood_size)
+void CNode::MarkReceivedMsgsForProcessing()
{
AssertLockNotHeld(m_msg_process_queue_mutex);
@@ -2809,10 +2812,10 @@ void CNode::MarkReceivedMsgsForProcessing(unsigned int recv_flood_size)
LOCK(m_msg_process_queue_mutex);
m_msg_process_queue.splice(m_msg_process_queue.end(), vRecvMsg);
m_msg_process_queue_size += nSizeAdded;
- fPauseRecv = m_msg_process_queue_size > recv_flood_size;
+ fPauseRecv = m_msg_process_queue_size > m_recv_flood_size;
}
-std::optional<std::pair<CNetMessage, bool>> CNode::PollMessage(size_t recv_flood_size)
+std::optional<std::pair<CNetMessage, bool>> CNode::PollMessage()
{
LOCK(m_msg_process_queue_mutex);
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
// Just take one message
msgs.splice(msgs.begin(), m_msg_process_queue, m_msg_process_queue.begin());
m_msg_process_queue_size -= msgs.front().m_raw_message_size;
- fPauseRecv = m_msg_process_queue_size > recv_flood_size;
+ fPauseRecv = m_msg_process_queue_size > m_recv_flood_size;
return std::make_pair(std::move(msgs.front()), !m_msg_process_queue.empty());
}