Skip to content

Commit aff6584

Browse files
committed
net: constify a few CNode vars to indicate that they're threadsafe
1 parent 3d69ecb commit aff6584

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/net.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,9 +2512,13 @@ unsigned int CConnman::GetSendBufferSize() const{ return nSendBufferMaxSize; }
25122512
CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, const std::string& addrNameIn, bool fInboundIn) :
25132513
ssSend(SER_NETWORK, INIT_PROTO_VERSION),
25142514
addr(addrIn),
2515+
fInbound(fInboundIn),
2516+
id(idIn),
25152517
nKeyedNetGroup(nKeyedNetGroupIn),
25162518
addrKnown(5000, 0.001),
2517-
filterInventoryKnown(50000, 0.000001)
2519+
filterInventoryKnown(50000, 0.000001),
2520+
nLocalServices(nLocalServicesIn),
2521+
nMyStartingHeight(nMyStartingHeightIn)
25182522
{
25192523
nServices = NODE_NONE;
25202524
nServicesExpected = NODE_NONE;
@@ -2533,7 +2537,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
25332537
fOneShot = false;
25342538
fClient = false; // set by version message
25352539
fFeeler = false;
2536-
fInbound = fInboundIn;
25372540
fNetworkNode = false;
25382541
fSuccessfullyConnected = false;
25392542
fDisconnect = false;
@@ -2562,12 +2565,8 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
25622565
minFeeFilter = 0;
25632566
lastSentFeeFilter = 0;
25642567
nextSendTimeFeeFilter = 0;
2565-
id = idIn;
25662568
nOptimisticBytesWritten = 0;
2567-
nLocalServices = nLocalServicesIn;
2568-
25692569
GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
2570-
nMyStartingHeight = nMyStartingHeightIn;
25712570

25722571
BOOST_FOREACH(const std::string &msg, getAllNetMessageTypes())
25732572
mapRecvBytesPerMsgCmd[msg] = 0;

src/net.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ class CNode
589589
bool fFeeler; // If true this node is being used as a short lived feeler.
590590
bool fOneShot;
591591
bool fClient;
592-
bool fInbound;
592+
const bool fInbound;
593593
bool fNetworkNode;
594594
bool fSuccessfullyConnected;
595595
bool fDisconnect;
@@ -603,7 +603,7 @@ class CNode
603603
CCriticalSection cs_filter;
604604
CBloomFilter* pfilter;
605605
int nRefCount;
606-
NodeId id;
606+
const NodeId id;
607607

608608
const uint64_t nKeyedNetGroup;
609609
protected:
@@ -679,8 +679,8 @@ class CNode
679679

680680
uint64_t nLocalHostNonce;
681681
// Services offered to this peer
682-
ServiceFlags nLocalServices;
683-
int nMyStartingHeight;
682+
const ServiceFlags nLocalServices;
683+
const int nMyStartingHeight;
684684
public:
685685

686686
NodeId GetId() const {

0 commit comments

Comments
 (0)