@@ -646,80 +646,80 @@ class CNode
646646 friend class CConnman ;
647647public:
648648 // socket
649- std::atomic<ServiceFlags> nServices;
649+ std::atomic<ServiceFlags> nServices{NODE_NONE} ;
650650 SOCKET hSocket GUARDED_BY (cs_hSocket);
651- size_t nSendSize; // total size of all vSendMsg entries
652- size_t nSendOffset; // offset inside the first vSendMsg already sent
653- uint64_t nSendBytes GUARDED_BY (cs_vSend);
651+ size_t nSendSize{ 0 } ; // total size of all vSendMsg entries
652+ size_t nSendOffset{ 0 } ; // offset inside the first vSendMsg already sent
653+ uint64_t nSendBytes GUARDED_BY (cs_vSend){ 0 } ;
654654 std::deque<std::vector<unsigned char >> vSendMsg GUARDED_BY (cs_vSend);
655655 CCriticalSection cs_vSend;
656656 CCriticalSection cs_hSocket;
657657 CCriticalSection cs_vRecv;
658658
659659 CCriticalSection cs_vProcessMsg;
660660 std::list<CNetMessage> vProcessMsg GUARDED_BY (cs_vProcessMsg);
661- size_t nProcessQueueSize;
661+ size_t nProcessQueueSize{ 0 } ;
662662
663663 CCriticalSection cs_sendProcessing;
664664
665665 std::deque<CInv> vRecvGetData;
666- uint64_t nRecvBytes GUARDED_BY (cs_vRecv);
667- std::atomic<int > nRecvVersion;
666+ uint64_t nRecvBytes GUARDED_BY (cs_vRecv){ 0 } ;
667+ std::atomic<int > nRecvVersion{INIT_PROTO_VERSION} ;
668668
669- std::atomic<int64_t > nLastSend;
670- std::atomic<int64_t > nLastRecv;
669+ std::atomic<int64_t > nLastSend{ 0 } ;
670+ std::atomic<int64_t > nLastRecv{ 0 } ;
671671 const int64_t nTimeConnected;
672- std::atomic<int64_t > nTimeOffset;
672+ std::atomic<int64_t > nTimeOffset{ 0 } ;
673673 // Address of this peer
674674 const CAddress addr;
675675 // Bind address of our side of the connection
676676 const CAddress addrBind;
677- std::atomic<int > nVersion;
677+ std::atomic<int > nVersion{ 0 } ;
678678 // strSubVer is whatever byte array we read from the wire. However, this field is intended
679679 // to be printed out, displayed to humans in various forms and so on. So we sanitize it and
680680 // store the sanitized version in cleanSubVer. The original should be used when dealing with
681681 // the network or wire types and the cleaned string used when displayed or logged.
682682 std::string strSubVer GUARDED_BY (cs_SubVer), cleanSubVer GUARDED_BY(cs_SubVer);
683683 CCriticalSection cs_SubVer; // used for both cleanSubVer and strSubVer
684- bool fWhitelisted ; // This peer can bypass DoS banning.
685- bool fFeeler ; // If true this node is being used as a short lived feeler.
686- bool fOneShot ;
687- bool m_manual_connection;
688- bool fClient ;
689- bool m_limited_node; // after BIP159
684+ bool fWhitelisted { false } ; // This peer can bypass DoS banning.
685+ bool fFeeler { false } ; // If true this node is being used as a short lived feeler.
686+ bool fOneShot { false } ;
687+ bool m_manual_connection{ false } ;
688+ bool fClient { false }; // set by version message
689+ bool m_limited_node{ false } ; // after BIP159, set by version message
690690 const bool fInbound ;
691- std::atomic_bool fSuccessfullyConnected ;
692- std::atomic_bool fDisconnect ;
691+ std::atomic_bool fSuccessfullyConnected { false } ;
692+ std::atomic_bool fDisconnect { false } ;
693693 // We use fRelayTxes for two purposes -
694694 // a) it allows us to not relay tx invs before receiving the peer's version message
695695 // b) the peer may tell us in its version message that we should not relay tx invs
696696 // unless it loads a bloom filter.
697- bool fRelayTxes GUARDED_BY (cs_filter);
698- bool fSentAddr ;
697+ bool fRelayTxes GUARDED_BY (cs_filter){ false } ;
698+ bool fSentAddr { false } ;
699699 CSemaphoreGrant grantOutbound;
700700 mutable CCriticalSection cs_filter;
701701 std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY (cs_filter);
702- std::atomic<int > nRefCount;
702+ std::atomic<int > nRefCount{ 0 } ;
703703
704704 const uint64_t nKeyedNetGroup;
705- std::atomic_bool fPauseRecv ;
706- std::atomic_bool fPauseSend ;
705+ std::atomic_bool fPauseRecv { false } ;
706+ std::atomic_bool fPauseSend { false } ;
707707
708708protected:
709709 mapMsgCmdSize mapSendBytesPerMsgCmd;
710710 mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY (cs_vRecv);
711711
712712public:
713713 uint256 hashContinue;
714- std::atomic<int > nStartingHeight;
714+ std::atomic<int > nStartingHeight{- 1 } ;
715715
716716 // flood relay
717717 std::vector<CAddress> vAddrToSend;
718718 CRollingBloomFilter addrKnown;
719- bool fGetAddr ;
719+ bool fGetAddr { false } ;
720720 std::set<uint256> setKnown;
721- int64_t nNextAddrSend GUARDED_BY (cs_sendProcessing);
722- int64_t nNextLocalAddrSend GUARDED_BY (cs_sendProcessing);
721+ int64_t nNextAddrSend GUARDED_BY (cs_sendProcessing){ 0 } ;
722+ int64_t nNextLocalAddrSend GUARDED_BY (cs_sendProcessing){ 0 } ;
723723
724724 // inventory based relay
725725 CRollingBloomFilter filterInventoryKnown GUARDED_BY (cs_inventory);
@@ -733,35 +733,35 @@ class CNode
733733 CCriticalSection cs_inventory;
734734 std::set<uint256> setAskFor;
735735 std::multimap<int64_t , CInv> mapAskFor;
736- int64_t nNextInvSend;
736+ int64_t nNextInvSend{ 0 } ;
737737 // Used for headers announcements - unfiltered blocks to relay
738738 std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY (cs_inventory);
739739 // Used for BIP35 mempool sending
740- bool fSendMempool GUARDED_BY (cs_inventory);
740+ bool fSendMempool GUARDED_BY (cs_inventory){ false } ;
741741
742742 // Last time a "MEMPOOL" request was serviced.
743- std::atomic<int64_t > timeLastMempoolReq;
743+ std::atomic<int64_t > timeLastMempoolReq{ 0 } ;
744744
745745 // Block and TXN accept times
746- std::atomic<int64_t > nLastBlockTime;
747- std::atomic<int64_t > nLastTXTime;
746+ std::atomic<int64_t > nLastBlockTime{ 0 } ;
747+ std::atomic<int64_t > nLastTXTime{ 0 } ;
748748
749749 // Ping time measurement:
750750 // The pong reply we're expecting, or 0 if no pong expected.
751- std::atomic<uint64_t > nPingNonceSent;
751+ std::atomic<uint64_t > nPingNonceSent{ 0 } ;
752752 // Time (in usec) the last ping was sent, or 0 if no ping was ever sent.
753- std::atomic<int64_t > nPingUsecStart;
753+ std::atomic<int64_t > nPingUsecStart{ 0 } ;
754754 // Last measured round-trip time.
755- std::atomic<int64_t > nPingUsecTime;
755+ std::atomic<int64_t > nPingUsecTime{ 0 } ;
756756 // Best measured round-trip time.
757- std::atomic<int64_t > nMinPingUsecTime;
757+ std::atomic<int64_t > nMinPingUsecTime{std::numeric_limits< int64_t >:: max ()} ;
758758 // Whether a ping is requested.
759- std::atomic<bool > fPingQueued ;
759+ std::atomic<bool > fPingQueued { false } ;
760760 // Minimum fee rate with which to filter inv's to this node
761- CAmount minFeeFilter GUARDED_BY (cs_feeFilter);
761+ CAmount minFeeFilter GUARDED_BY (cs_feeFilter){ 0 } ;
762762 CCriticalSection cs_feeFilter;
763- CAmount lastSentFeeFilter;
764- int64_t nextSendTimeFeeFilter;
763+ CAmount lastSentFeeFilter{ 0 } ;
764+ int64_t nextSendTimeFeeFilter{ 0 } ;
765765
766766 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 );
767767 ~CNode ();
@@ -774,7 +774,7 @@ class CNode
774774 // Services offered to this peer
775775 const ServiceFlags nLocalServices;
776776 const int nMyStartingHeight;
777- int nSendVersion;
777+ int nSendVersion{ 0 } ;
778778 std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
779779
780780 mutable CCriticalSection cs_addrName;
0 commit comments