mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
Merge #21370: Use C++11 member initializer in CNodeState
fa476f188e
Use C++11 member initializer in CNodeState (MarcoFalke) Pull request description: This removes a bunch of boilerplate, makes the code easier to read. Also, C++11 member initialization avoids accidental uninitialized members. ACKs for top commit: practicalswift: cr ACKfa476f188e
hebasto: cr ACKfa476f188e
jnewbery: utACKfa476f188e
Tree-SHA512: 5c876717d30ded975e29bfbc77804012179588a13f950f0b2ec93fa9dbd5cf6b52fe86414fd5d1cce021db2ec77e271d533b0f7a8d6eeaac0feb9e6dbaec9ff2
This commit is contained in:
commit
e175ca9c65
1 changed files with 18 additions and 35 deletions
|
@ -491,17 +491,17 @@ struct CNodeState {
|
|||
//! The peer's address
|
||||
const CService address;
|
||||
//! The best known block we know this peer has announced.
|
||||
const CBlockIndex *pindexBestKnownBlock;
|
||||
const CBlockIndex* pindexBestKnownBlock{nullptr};
|
||||
//! The hash of the last unknown block this peer has announced.
|
||||
uint256 hashLastUnknownBlock;
|
||||
uint256 hashLastUnknownBlock{};
|
||||
//! The last full block we both have.
|
||||
const CBlockIndex *pindexLastCommonBlock;
|
||||
const CBlockIndex* pindexLastCommonBlock{nullptr};
|
||||
//! The best header we have sent our peer.
|
||||
const CBlockIndex *pindexBestHeaderSent;
|
||||
const CBlockIndex* pindexBestHeaderSent{nullptr};
|
||||
//! Length of current-streak of unconnecting headers announcements
|
||||
int nUnconnectingHeaders;
|
||||
int nUnconnectingHeaders{0};
|
||||
//! Whether we've started headers synchronization with this peer.
|
||||
bool fSyncStarted;
|
||||
bool fSyncStarted{false};
|
||||
//! When to potentially disconnect peer for stalling headers download
|
||||
std::chrono::microseconds m_headers_sync_timeout{0us};
|
||||
//! Since when we're stalling block download progress (in microseconds), or 0.
|
||||
|
@ -509,29 +509,29 @@ struct CNodeState {
|
|||
std::list<QueuedBlock> vBlocksInFlight;
|
||||
//! When the first entry in vBlocksInFlight started downloading. Don't care when vBlocksInFlight is empty.
|
||||
std::chrono::microseconds m_downloading_since{0us};
|
||||
int nBlocksInFlight;
|
||||
int nBlocksInFlightValidHeaders;
|
||||
int nBlocksInFlight{0};
|
||||
int nBlocksInFlightValidHeaders{0};
|
||||
//! Whether we consider this a preferred download peer.
|
||||
bool fPreferredDownload;
|
||||
bool fPreferredDownload{false};
|
||||
//! Whether this peer wants invs or headers (when possible) for block announcements.
|
||||
bool fPreferHeaders;
|
||||
bool fPreferHeaders{false};
|
||||
//! Whether this peer wants invs or cmpctblocks (when possible) for block announcements.
|
||||
bool fPreferHeaderAndIDs;
|
||||
bool fPreferHeaderAndIDs{false};
|
||||
/**
|
||||
* Whether this peer will send us cmpctblocks if we request them.
|
||||
* This is not used to gate request logic, as we really only care about fSupportsDesiredCmpctVersion,
|
||||
* but is used as a flag to "lock in" the version of compact blocks (fWantsCmpctWitness) we send.
|
||||
*/
|
||||
bool fProvidesHeaderAndIDs;
|
||||
bool fProvidesHeaderAndIDs{false};
|
||||
//! Whether this peer can give us witnesses
|
||||
bool fHaveWitness;
|
||||
bool fHaveWitness{false};
|
||||
//! Whether this peer wants witnesses in cmpctblocks/blocktxns
|
||||
bool fWantsCmpctWitness;
|
||||
bool fWantsCmpctWitness{false};
|
||||
/**
|
||||
* If we've announced NODE_WITNESS to this peer: whether the peer sends witnesses in cmpctblocks/blocktxns,
|
||||
* otherwise: whether this peer sends non-witnesses in cmpctblocks/blocktxns.
|
||||
*/
|
||||
bool fSupportsDesiredCmpctVersion;
|
||||
bool fSupportsDesiredCmpctVersion{false};
|
||||
|
||||
/** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic.
|
||||
*
|
||||
|
@ -568,13 +568,13 @@ struct CNodeState {
|
|||
bool m_protect;
|
||||
};
|
||||
|
||||
ChainSyncTimeoutState m_chain_sync;
|
||||
ChainSyncTimeoutState m_chain_sync{0, nullptr, false, false};
|
||||
|
||||
//! Time of last new block announcement
|
||||
int64_t m_last_block_announcement;
|
||||
int64_t m_last_block_announcement{0};
|
||||
|
||||
//! Whether this peer is an inbound connection
|
||||
bool m_is_inbound;
|
||||
const bool m_is_inbound;
|
||||
|
||||
//! A rolling bloom filter of all announced tx CInvs to this peer.
|
||||
CRollingBloomFilter m_recently_announced_invs = CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001};
|
||||
|
@ -585,23 +585,6 @@ struct CNodeState {
|
|||
CNodeState(CAddress addrIn, bool is_inbound)
|
||||
: address(addrIn), m_is_inbound(is_inbound)
|
||||
{
|
||||
pindexBestKnownBlock = nullptr;
|
||||
hashLastUnknownBlock.SetNull();
|
||||
pindexLastCommonBlock = nullptr;
|
||||
pindexBestHeaderSent = nullptr;
|
||||
nUnconnectingHeaders = 0;
|
||||
fSyncStarted = false;
|
||||
nBlocksInFlight = 0;
|
||||
nBlocksInFlightValidHeaders = 0;
|
||||
fPreferredDownload = false;
|
||||
fPreferHeaders = false;
|
||||
fPreferHeaderAndIDs = false;
|
||||
fProvidesHeaderAndIDs = false;
|
||||
fHaveWitness = false;
|
||||
fWantsCmpctWitness = false;
|
||||
fSupportsDesiredCmpctVersion = false;
|
||||
m_chain_sync = { 0, nullptr, false, false };
|
||||
m_last_block_announcement = 0;
|
||||
m_recently_announced_invs.reset();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue