net/net_processing: Add thread safety related annotations for CNode and Peer
Summary:
Adds GUARDED_BY and const annotations to document how we currently ensure various members of CNode and Peer aren't subject to race conditions.
net/net_processing: add missing thread safety annotations
https://github.com/bitcoin/bitcoin/pull/25174/commits/06ebdc886fcb4ca22f695bafe0956cff6d70a250
net: mark TransportSerializer/m_serializer as const
The (V1)TransportSerializer instance CNode::m_serializer is used from
multiple threads via PushMessage without protection by a mutex. This
is only thread safe because the class does not have any mutable state,
so document that by marking the methods and the object as "const".
https://github.com/bitcoin/bitcoin/pull/25174/commits/bbec32c9ad2fe213314db9d39aa1eacff2e0bc23
net: mark CNode unique_ptr members as const
Dereferencing a unique_ptr is not necessarily thread safe. The reason
these are safe is because their values are set at construction and do
not change later; so mark them as const and set them via the initializer
list to guarantee that.
https://github.com/bitcoin/bitcoin/pull/25174/commits/ef26f2f421071986a3878a1a94b0149ae8e16fcd
The last commit adding comments about constness is bypassed by D17110 which makes the members actually const.
This is a backport of core#25174
Depends on D18249
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18250