@@ -640,80 +640,80 @@ class CNode
640640 friend class CConnman ;
641641public:
642642 // socket
643- std::atomic<ServiceFlags> nServices;
643+ std::atomic<ServiceFlags> nServices{NODE_NONE} ;
644644 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 } ;
648648 std::deque<std::vector<unsigned char >> vSendMsg GUARDED_BY (cs_vSend);
649649 CCriticalSection cs_vSend;
650650 CCriticalSection cs_hSocket;
651651 CCriticalSection cs_vRecv;
652652
653653 CCriticalSection cs_vProcessMsg;
654654 std::list<CNetMessage> vProcessMsg GUARDED_BY (cs_vProcessMsg);
655- size_t nProcessQueueSize;
655+ size_t nProcessQueueSize{ 0 } ;
656656
657657 CCriticalSection cs_sendProcessing;
658658
659659 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} ;
662662
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 } ;
665665 const int64_t nTimeConnected;
666- std::atomic<int64_t > nTimeOffset;
666+ std::atomic<int64_t > nTimeOffset{ 0 } ;
667667 // Address of this peer
668668 const CAddress addr;
669669 // Bind address of our side of the connection
670670 const CAddress addrBind;
671- std::atomic<int > nVersion;
671+ std::atomic<int > nVersion{ 0 } ;
672672 // strSubVer is whatever byte array we read from the wire. However, this field is intended
673673 // to be printed out, displayed to humans in various forms and so on. So we sanitize it and
674674 // store the sanitized version in cleanSubVer. The original should be used when dealing with
675675 // the network or wire types and the cleaned string used when displayed or logged.
676676 std::string strSubVer GUARDED_BY (cs_SubVer), cleanSubVer GUARDED_BY(cs_SubVer);
677677 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
684684 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 } ;
687687 // We use fRelayTxes for two purposes -
688688 // a) it allows us to not relay tx invs before receiving the peer's version message
689689 // b) the peer may tell us in its version message that we should not relay tx invs
690690 // 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 } ;
693693 CSemaphoreGrant grantOutbound;
694694 mutable CCriticalSection cs_filter;
695695 std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY (cs_filter);
696- std::atomic<int > nRefCount;
696+ std::atomic<int > nRefCount{ 0 } ;
697697
698698 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 } ;
701701
702702protected:
703703 mapMsgCmdSize mapSendBytesPerMsgCmd;
704704 mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY (cs_vRecv);
705705
706706public:
707707 uint256 hashContinue;
708- std::atomic<int > nStartingHeight;
708+ std::atomic<int > nStartingHeight{- 1 } ;
709709
710710 // flood relay
711711 std::vector<CAddress> vAddrToSend;
712712 CRollingBloomFilter addrKnown;
713- bool fGetAddr ;
713+ bool fGetAddr { false } ;
714714 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 } ;
717717
718718 // inventory based relay
719719 CRollingBloomFilter filterInventoryKnown GUARDED_BY (cs_inventory);
@@ -727,35 +727,35 @@ class CNode
727727 CCriticalSection cs_inventory;
728728 std::set<uint256> setAskFor;
729729 std::multimap<int64_t , CInv> mapAskFor;
730- int64_t nNextInvSend;
730+ int64_t nNextInvSend{ 0 } ;
731731 // Used for headers announcements - unfiltered blocks to relay
732732 std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY (cs_inventory);
733733 // Used for BIP35 mempool sending
734- bool fSendMempool GUARDED_BY (cs_inventory);
734+ bool fSendMempool GUARDED_BY (cs_inventory){ false } ;
735735
736736 // Last time a "MEMPOOL" request was serviced.
737- std::atomic<int64_t > timeLastMempoolReq;
737+ std::atomic<int64_t > timeLastMempoolReq{ 0 } ;
738738
739739 // 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 } ;
742742
743743 // Ping time measurement:
744744 // 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 } ;
746746 // 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 } ;
748748 // Last measured round-trip time.
749- std::atomic<int64_t > nPingUsecTime;
749+ std::atomic<int64_t > nPingUsecTime{ 0 } ;
750750 // Best measured round-trip time.
751- std::atomic<int64_t > nMinPingUsecTime;
751+ std::atomic<int64_t > nMinPingUsecTime{std::numeric_limits< int64_t >:: max ()} ;
752752 // Whether a ping is requested.
753- std::atomic<bool > fPingQueued ;
753+ std::atomic<bool > fPingQueued { false } ;
754754 // 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 } ;
756756 CCriticalSection cs_feeFilter;
757- CAmount lastSentFeeFilter;
758- int64_t nextSendTimeFeeFilter;
757+ CAmount lastSentFeeFilter{ 0 } ;
758+ int64_t nextSendTimeFeeFilter{ 0 } ;
759759
760760 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 );
761761 ~CNode ();
@@ -768,7 +768,7 @@ class CNode
768768 // Services offered to this peer
769769 const ServiceFlags nLocalServices;
770770 const int nMyStartingHeight;
771- int nSendVersion;
771+ int nSendVersion{ 0 } ;
772772 std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
773773
774774 mutable CCriticalSection cs_addrName;
0 commit comments