net: prevent sending messages in NetEventsInterface::InitializeNode

Now that the queueing of the VERSION messages has been moved out of
`InitializeNode`, there is no need to pass a mutable `CNode` reference any
more. With a const reference, trying to send messages in this method would
lead to a compile-time error, e.g.:

----------------------------------------------------------------------------------------------------------------------------------
...
net_processing.cpp: In member function ‘virtual void {anonymous}::PeerManagerImpl::InitializeNode(const CNode&, ServiceFlags)’:
net_processing.cpp:1683:21: error: binding reference of type ‘CNode&’ to ‘const CNode’ discards qualifiers
 1683 |     PushNodeVersion(node, *peer);
...
----------------------------------------------------------------------------------------------------------------------------------
This commit is contained in:
Sebastian Falbesoner 2024-07-09 12:18:23 +02:00
parent 66673f1c13
commit 0dbcd4c148
2 changed files with 3 additions and 3 deletions

View file

@ -992,7 +992,7 @@ public:
static Mutex g_msgproc_mutex; static Mutex g_msgproc_mutex;
/** Initialize a peer (setup state) */ /** Initialize a peer (setup state) */
virtual void InitializeNode(CNode& node, ServiceFlags our_services) = 0; virtual void InitializeNode(const CNode& node, ServiceFlags our_services) = 0;
/** Handle removal of a peer (clear state) */ /** Handle removal of a peer (clear state) */
virtual void FinalizeNode(const CNode& node) = 0; virtual void FinalizeNode(const CNode& node) = 0;

View file

@ -501,7 +501,7 @@ public:
EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex); EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex);
/** Implement NetEventsInterface */ /** Implement NetEventsInterface */
void InitializeNode(CNode& node, ServiceFlags our_services) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); void InitializeNode(const CNode& node, ServiceFlags our_services) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void FinalizeNode(const CNode& node) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_headers_presync_mutex); void FinalizeNode(const CNode& node) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_headers_presync_mutex);
bool HasAllDesirableServiceFlags(ServiceFlags services) const override; bool HasAllDesirableServiceFlags(ServiceFlags services) const override;
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override
@ -1662,7 +1662,7 @@ void PeerManagerImpl::UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_s
if (state) state->m_last_block_announcement = time_in_seconds; if (state) state->m_last_block_announcement = time_in_seconds;
} }
void PeerManagerImpl::InitializeNode(CNode& node, ServiceFlags our_services) void PeerManagerImpl::InitializeNode(const CNode& node, ServiceFlags our_services)
{ {
NodeId nodeid = node.GetId(); NodeId nodeid = node.GetId();
{ {