@@ -640,80 +640,80 @@ class CNode
640
640
friend class CConnman ;
641
641
public:
642
642
// socket
643
- std::atomic<ServiceFlags> nServices;
643
+ std::atomic<ServiceFlags> nServices{NODE_NONE} ;
644
644
SOCKET hSocket GUARDED_BY (cs_hSocket);
645
- size_t nSendSize; // total size of all vSendMsg entries
646
- size_t nSendOffset; // offset inside the first vSendMsg already sent
647
- uint64_t nSendBytes GUARDED_BY (cs_vSend);
645
+ size_t nSendSize{ 0 } ; // total size of all vSendMsg entries
646
+ size_t nSendOffset{ 0 } ; // offset inside the first vSendMsg already sent
647
+ uint64_t nSendBytes GUARDED_BY (cs_vSend){ 0 } ;
648
648
std::deque<std::vector<unsigned char >> vSendMsg GUARDED_BY (cs_vSend);
649
649
CCriticalSection cs_vSend;
650
650
CCriticalSection cs_hSocket;
651
651
CCriticalSection cs_vRecv;
652
652
653
653
CCriticalSection cs_vProcessMsg;
654
654
std::list<CNetMessage> vProcessMsg GUARDED_BY (cs_vProcessMsg);
655
- size_t nProcessQueueSize;
655
+ size_t nProcessQueueSize{ 0 } ;
656
656
657
657
CCriticalSection cs_sendProcessing;
658
658
659
659
std::deque<CInv> vRecvGetData;
660
- uint64_t nRecvBytes GUARDED_BY (cs_vRecv);
661
- std::atomic<int > nRecvVersion;
660
+ uint64_t nRecvBytes GUARDED_BY (cs_vRecv){ 0 } ;
661
+ std::atomic<int > nRecvVersion{INIT_PROTO_VERSION} ;
662
662
663
- std::atomic<int64_t > nLastSend;
664
- std::atomic<int64_t > nLastRecv;
663
+ std::atomic<int64_t > nLastSend{ 0 } ;
664
+ std::atomic<int64_t > nLastRecv{ 0 } ;
665
665
const int64_t nTimeConnected;
666
- std::atomic<int64_t > nTimeOffset;
666
+ std::atomic<int64_t > nTimeOffset{ 0 } ;
667
667
// Address of this peer
668
668
const CAddress addr;
669
669
// Bind address of our side of the connection
670
670
const CAddress addrBind;
671
- std::atomic<int > nVersion;
671
+ std::atomic<int > nVersion{ 0 } ;
672
672
// strSubVer is whatever byte array we read from the wire. However, this field is intended
673
673
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
674
674
// store the sanitized version in cleanSubVer. The original should be used when dealing with
675
675
// the network or wire types and the cleaned string used when displayed or logged.
676
676
std::string strSubVer GUARDED_BY (cs_SubVer), cleanSubVer GUARDED_BY(cs_SubVer);
677
677
CCriticalSection cs_SubVer; // used for both cleanSubVer and strSubVer
678
- bool fWhitelisted ; // This peer can bypass DoS banning.
679
- bool fFeeler ; // If true this node is being used as a short lived feeler.
680
- bool fOneShot ;
681
- bool m_manual_connection;
682
- bool fClient ;
683
- bool m_limited_node; // after BIP159
678
+ bool fWhitelisted { false } ; // This peer can bypass DoS banning.
679
+ bool fFeeler { false } ; // If true this node is being used as a short lived feeler.
680
+ bool fOneShot { false } ;
681
+ bool m_manual_connection{ false } ;
682
+ bool fClient { false }; // set by version message
683
+ bool m_limited_node{ false } ; // after BIP159, set by version message
684
684
const bool fInbound ;
685
- std::atomic_bool fSuccessfullyConnected ;
686
- std::atomic_bool fDisconnect ;
685
+ std::atomic_bool fSuccessfullyConnected { false } ;
686
+ std::atomic_bool fDisconnect { false } ;
687
687
// We use fRelayTxes for two purposes -
688
688
// a) it allows us to not relay tx invs before receiving the peer's version message
689
689
// b) the peer may tell us in its version message that we should not relay tx invs
690
690
// unless it loads a bloom filter.
691
- bool fRelayTxes GUARDED_BY (cs_filter);
692
- bool fSentAddr ;
691
+ bool fRelayTxes GUARDED_BY (cs_filter){ false } ;
692
+ bool fSentAddr { false } ;
693
693
CSemaphoreGrant grantOutbound;
694
694
mutable CCriticalSection cs_filter;
695
695
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY (cs_filter);
696
- std::atomic<int > nRefCount;
696
+ std::atomic<int > nRefCount{ 0 } ;
697
697
698
698
const uint64_t nKeyedNetGroup;
699
- std::atomic_bool fPauseRecv ;
700
- std::atomic_bool fPauseSend ;
699
+ std::atomic_bool fPauseRecv { false } ;
700
+ std::atomic_bool fPauseSend { false } ;
701
701
702
702
protected:
703
703
mapMsgCmdSize mapSendBytesPerMsgCmd;
704
704
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY (cs_vRecv);
705
705
706
706
public:
707
707
uint256 hashContinue;
708
- std::atomic<int > nStartingHeight;
708
+ std::atomic<int > nStartingHeight{- 1 } ;
709
709
710
710
// flood relay
711
711
std::vector<CAddress> vAddrToSend;
712
712
CRollingBloomFilter addrKnown;
713
- bool fGetAddr ;
713
+ bool fGetAddr { false } ;
714
714
std::set<uint256> setKnown;
715
- int64_t nNextAddrSend GUARDED_BY (cs_sendProcessing);
716
- int64_t nNextLocalAddrSend GUARDED_BY (cs_sendProcessing);
715
+ int64_t nNextAddrSend GUARDED_BY (cs_sendProcessing){ 0 } ;
716
+ int64_t nNextLocalAddrSend GUARDED_BY (cs_sendProcessing){ 0 } ;
717
717
718
718
// inventory based relay
719
719
CRollingBloomFilter filterInventoryKnown GUARDED_BY (cs_inventory);
@@ -727,35 +727,35 @@ class CNode
727
727
CCriticalSection cs_inventory;
728
728
std::set<uint256> setAskFor;
729
729
std::multimap<int64_t , CInv> mapAskFor;
730
- int64_t nNextInvSend;
730
+ int64_t nNextInvSend{ 0 } ;
731
731
// Used for headers announcements - unfiltered blocks to relay
732
732
std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY (cs_inventory);
733
733
// Used for BIP35 mempool sending
734
- bool fSendMempool GUARDED_BY (cs_inventory);
734
+ bool fSendMempool GUARDED_BY (cs_inventory){ false } ;
735
735
736
736
// Last time a "MEMPOOL" request was serviced.
737
- std::atomic<int64_t > timeLastMempoolReq;
737
+ std::atomic<int64_t > timeLastMempoolReq{ 0 } ;
738
738
739
739
// Block and TXN accept times
740
- std::atomic<int64_t > nLastBlockTime;
741
- std::atomic<int64_t > nLastTXTime;
740
+ std::atomic<int64_t > nLastBlockTime{ 0 } ;
741
+ std::atomic<int64_t > nLastTXTime{ 0 } ;
742
742
743
743
// Ping time measurement:
744
744
// The pong reply we're expecting, or 0 if no pong expected.
745
- std::atomic<uint64_t > nPingNonceSent;
745
+ std::atomic<uint64_t > nPingNonceSent{ 0 } ;
746
746
// Time (in usec) the last ping was sent, or 0 if no ping was ever sent.
747
- std::atomic<int64_t > nPingUsecStart;
747
+ std::atomic<int64_t > nPingUsecStart{ 0 } ;
748
748
// Last measured round-trip time.
749
- std::atomic<int64_t > nPingUsecTime;
749
+ std::atomic<int64_t > nPingUsecTime{ 0 } ;
750
750
// Best measured round-trip time.
751
- std::atomic<int64_t > nMinPingUsecTime;
751
+ std::atomic<int64_t > nMinPingUsecTime{std::numeric_limits< int64_t >:: max ()} ;
752
752
// Whether a ping is requested.
753
- std::atomic<bool > fPingQueued ;
753
+ std::atomic<bool > fPingQueued { false } ;
754
754
// Minimum fee rate with which to filter inv's to this node
755
- CAmount minFeeFilter GUARDED_BY (cs_feeFilter);
755
+ CAmount minFeeFilter GUARDED_BY (cs_feeFilter){ 0 } ;
756
756
CCriticalSection cs_feeFilter;
757
- CAmount lastSentFeeFilter;
758
- int64_t nextSendTimeFeeFilter;
757
+ CAmount lastSentFeeFilter{ 0 } ;
758
+ int64_t nextSendTimeFeeFilter{ 0 } ;
759
759
760
760
CNode (NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn = " " , bool fInboundIn = false );
761
761
~CNode ();
@@ -768,7 +768,7 @@ class CNode
768
768
// Services offered to this peer
769
769
const ServiceFlags nLocalServices;
770
770
const int nMyStartingHeight;
771
- int nSendVersion;
771
+ int nSendVersion{ 0 } ;
772
772
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
773
773
774
774
mutable CCriticalSection cs_addrName;
0 commit comments