mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge #20373: refactor, net: Increase CNode data member encapsulation
3642b2ed34
refactor, net: Increase CNode data member encapsulation (Hennadii Stepanov)acebb79d3f
refactor, move-only: Relocate CNode private members (Hennadii Stepanov) Pull request description: All protected `CNode` data members could be private. ACKs for top commit: jnewbery: utACK3642b2ed34
MarcoFalke: review ACK3642b2ed34
🏛 Tree-SHA512: 8435e3c43c3b7a3107d58cb809b8b5e1a1c0068677e249bdf0fc6ed24140ac4fc4efe2a280a1ee86df180d738c0c9e10772308690607954db6713000cf6e728d
This commit is contained in:
commit
5cce607105
1 changed files with 38 additions and 45 deletions
83
src/net.h
83
src/net.h
|
@ -528,11 +528,6 @@ public:
|
|||
*/
|
||||
Network ConnectedThroughNetwork() const;
|
||||
|
||||
protected:
|
||||
mapMsgCmdSize mapSendBytesPerMsgCmd GUARDED_BY(cs_vSend);
|
||||
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
||||
|
||||
public:
|
||||
// We selected peer as (compact blocks) high-bandwidth peer (BIP152)
|
||||
std::atomic<bool> m_bip152_highbandwidth_to{false};
|
||||
// Peer selected us as (compact blocks) high-bandwidth peer (BIP152)
|
||||
|
@ -604,43 +599,6 @@ public:
|
|||
CNode(const CNode&) = delete;
|
||||
CNode& operator=(const CNode&) = delete;
|
||||
|
||||
private:
|
||||
const NodeId id;
|
||||
const uint64_t nLocalHostNonce;
|
||||
const ConnectionType m_conn_type;
|
||||
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
|
||||
|
||||
//! Services offered to this peer.
|
||||
//!
|
||||
//! This is supplied by the parent CConnman during peer connection
|
||||
//! (CConnman::ConnectNode()) from its attribute of the same name.
|
||||
//!
|
||||
//! This is const because there is no protocol defined for renegotiating
|
||||
//! services initially offered to a peer. The set of local services we
|
||||
//! offer should not change after initialization.
|
||||
//!
|
||||
//! An interesting example of this is NODE_NETWORK and initial block
|
||||
//! download: a node which starts up from scratch doesn't have any blocks
|
||||
//! to serve, but still advertises NODE_NETWORK because it will eventually
|
||||
//! fulfill this role after IBD completes. P2P code is written in such a
|
||||
//! way that it can gracefully handle peers who don't make good on their
|
||||
//! service advertisements.
|
||||
const ServiceFlags nLocalServices;
|
||||
|
||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||
|
||||
mutable RecursiveMutex cs_addrName;
|
||||
std::string addrName GUARDED_BY(cs_addrName);
|
||||
|
||||
// Our address, as reported by the peer
|
||||
CService addrLocal GUARDED_BY(cs_addrLocal);
|
||||
mutable RecursiveMutex cs_addrLocal;
|
||||
|
||||
//! Whether this peer is an inbound onion, e.g. connected via our Tor onion service.
|
||||
const bool m_inbound_onion{false};
|
||||
|
||||
public:
|
||||
|
||||
NodeId GetId() const {
|
||||
return id;
|
||||
}
|
||||
|
@ -691,8 +649,6 @@ public:
|
|||
nRefCount--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddAddressKnown(const CAddress& _addr)
|
||||
{
|
||||
assert(m_addr_known);
|
||||
|
@ -724,7 +680,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void AddKnownTx(const uint256& hash)
|
||||
{
|
||||
if (m_tx_relay != nullptr) {
|
||||
|
@ -759,6 +714,44 @@ public:
|
|||
|
||||
/** Whether this peer is an inbound onion, e.g. connected via our Tor onion service. */
|
||||
bool IsInboundOnion() const { return m_inbound_onion; }
|
||||
|
||||
private:
|
||||
const NodeId id;
|
||||
const uint64_t nLocalHostNonce;
|
||||
const ConnectionType m_conn_type;
|
||||
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
|
||||
|
||||
//! Services offered to this peer.
|
||||
//!
|
||||
//! This is supplied by the parent CConnman during peer connection
|
||||
//! (CConnman::ConnectNode()) from its attribute of the same name.
|
||||
//!
|
||||
//! This is const because there is no protocol defined for renegotiating
|
||||
//! services initially offered to a peer. The set of local services we
|
||||
//! offer should not change after initialization.
|
||||
//!
|
||||
//! An interesting example of this is NODE_NETWORK and initial block
|
||||
//! download: a node which starts up from scratch doesn't have any blocks
|
||||
//! to serve, but still advertises NODE_NETWORK because it will eventually
|
||||
//! fulfill this role after IBD completes. P2P code is written in such a
|
||||
//! way that it can gracefully handle peers who don't make good on their
|
||||
//! service advertisements.
|
||||
const ServiceFlags nLocalServices;
|
||||
|
||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||
|
||||
mutable RecursiveMutex cs_addrName;
|
||||
std::string addrName GUARDED_BY(cs_addrName);
|
||||
|
||||
// Our address, as reported by the peer
|
||||
CService addrLocal GUARDED_BY(cs_addrLocal);
|
||||
mutable RecursiveMutex cs_addrLocal;
|
||||
|
||||
//! Whether this peer is an inbound onion, e.g. connected via our Tor onion service.
|
||||
const bool m_inbound_onion{false};
|
||||
|
||||
mapMsgCmdSize mapSendBytesPerMsgCmd GUARDED_BY(cs_vSend);
|
||||
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue