@@ -646,80 +646,80 @@ class CNode
646
646
friend class CConnman ;
647
647
public:
648
648
// socket
649
- std::atomic<ServiceFlags> nServices;
649
+ std::atomic<ServiceFlags> nServices{NODE_NONE} ;
650
650
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 } ;
654
654
std::deque<std::vector<unsigned char >> vSendMsg GUARDED_BY (cs_vSend);
655
655
CCriticalSection cs_vSend;
656
656
CCriticalSection cs_hSocket;
657
657
CCriticalSection cs_vRecv;
658
658
659
659
CCriticalSection cs_vProcessMsg;
660
660
std::list<CNetMessage> vProcessMsg GUARDED_BY (cs_vProcessMsg);
661
- size_t nProcessQueueSize;
661
+ size_t nProcessQueueSize{ 0 } ;
662
662
663
663
CCriticalSection cs_sendProcessing;
664
664
665
665
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} ;
668
668
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 } ;
671
671
const int64_t nTimeConnected;
672
- std::atomic<int64_t > nTimeOffset;
672
+ std::atomic<int64_t > nTimeOffset{ 0 } ;
673
673
// Address of this peer
674
674
const CAddress addr;
675
675
// Bind address of our side of the connection
676
676
const CAddress addrBind;
677
- std::atomic<int > nVersion;
677
+ std::atomic<int > nVersion{ 0 } ;
678
678
// strSubVer is whatever byte array we read from the wire. However, this field is intended
679
679
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
680
680
// store the sanitized version in cleanSubVer. The original should be used when dealing with
681
681
// the network or wire types and the cleaned string used when displayed or logged.
682
682
std::string strSubVer GUARDED_BY (cs_SubVer), cleanSubVer GUARDED_BY(cs_SubVer);
683
683
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
690
690
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 } ;
693
693
// We use fRelayTxes for two purposes -
694
694
// a) it allows us to not relay tx invs before receiving the peer's version message
695
695
// b) the peer may tell us in its version message that we should not relay tx invs
696
696
// 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 } ;
699
699
CSemaphoreGrant grantOutbound;
700
700
mutable CCriticalSection cs_filter;
701
701
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY (cs_filter);
702
- std::atomic<int > nRefCount;
702
+ std::atomic<int > nRefCount{ 0 } ;
703
703
704
704
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 } ;
707
707
708
708
protected:
709
709
mapMsgCmdSize mapSendBytesPerMsgCmd;
710
710
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY (cs_vRecv);
711
711
712
712
public:
713
713
uint256 hashContinue;
714
- std::atomic<int > nStartingHeight;
714
+ std::atomic<int > nStartingHeight{- 1 } ;
715
715
716
716
// flood relay
717
717
std::vector<CAddress> vAddrToSend;
718
718
CRollingBloomFilter addrKnown;
719
- bool fGetAddr ;
719
+ bool fGetAddr { false } ;
720
720
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 } ;
723
723
724
724
// inventory based relay
725
725
CRollingBloomFilter filterInventoryKnown GUARDED_BY (cs_inventory);
@@ -733,35 +733,35 @@ class CNode
733
733
CCriticalSection cs_inventory;
734
734
std::set<uint256> setAskFor;
735
735
std::multimap<int64_t , CInv> mapAskFor;
736
- int64_t nNextInvSend;
736
+ int64_t nNextInvSend{ 0 } ;
737
737
// Used for headers announcements - unfiltered blocks to relay
738
738
std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY (cs_inventory);
739
739
// Used for BIP35 mempool sending
740
- bool fSendMempool GUARDED_BY (cs_inventory);
740
+ bool fSendMempool GUARDED_BY (cs_inventory){ false } ;
741
741
742
742
// Last time a "MEMPOOL" request was serviced.
743
- std::atomic<int64_t > timeLastMempoolReq;
743
+ std::atomic<int64_t > timeLastMempoolReq{ 0 } ;
744
744
745
745
// 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 } ;
748
748
749
749
// Ping time measurement:
750
750
// 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 } ;
752
752
// 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 } ;
754
754
// Last measured round-trip time.
755
- std::atomic<int64_t > nPingUsecTime;
755
+ std::atomic<int64_t > nPingUsecTime{ 0 } ;
756
756
// Best measured round-trip time.
757
- std::atomic<int64_t > nMinPingUsecTime;
757
+ std::atomic<int64_t > nMinPingUsecTime{std::numeric_limits< int64_t >:: max ()} ;
758
758
// Whether a ping is requested.
759
- std::atomic<bool > fPingQueued ;
759
+ std::atomic<bool > fPingQueued { false } ;
760
760
// 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 } ;
762
762
CCriticalSection cs_feeFilter;
763
- CAmount lastSentFeeFilter;
764
- int64_t nextSendTimeFeeFilter;
763
+ CAmount lastSentFeeFilter{ 0 } ;
764
+ int64_t nextSendTimeFeeFilter{ 0 } ;
765
765
766
766
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 );
767
767
~CNode ();
@@ -774,7 +774,7 @@ class CNode
774
774
// Services offered to this peer
775
775
const ServiceFlags nLocalServices;
776
776
const int nMyStartingHeight;
777
- int nSendVersion;
777
+ int nSendVersion{ 0 } ;
778
778
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
779
779
780
780
mutable CCriticalSection cs_addrName;
0 commit comments