36 #include <condition_variable> 46 #include <unordered_set> 130 std::vector<unsigned char>
data;
234 std::chrono::microseconds m_time{0};
235 uint32_t m_message_size{0};
236 uint32_t m_raw_message_size{0};
268 virtual
bool ReceivedMessageComplete() const = 0;
276 virtual
bool ReceivedBytes(
Span<const uint8_t>& msg_bytes) = 0;
285 virtual
CNetMessage GetReceivedMessage(
std::chrono::microseconds time,
bool& reject_message) = 0;
305 Span<const uint8_t> ,
345 virtual
BytesToSend GetBytesToSend(
bool have_next_message) const noexcept = 0;
353 virtual
void MarkBytesSent(
size_t bytes_sent) noexcept = 0;
356 virtual
size_t GetSendMemoryUsage() const noexcept = 0;
361 virtual
bool ShouldReconnectV1() const noexcept = 0;
376 unsigned int nHdrPos
GUARDED_BY(m_recv_mutex);
377 unsigned int nDataPos
GUARDED_BY(m_recv_mutex);
398 if (!in_data)
return false;
399 return hdr.nMessageSize == nDataPos;
405 std::vector<uint8_t> m_header_to_send
GUARDED_BY(m_send_mutex);
419 return WITH_LOCK(m_recv_mutex,
return CompleteInternal());
422 Info
GetInfo() const noexcept override;
428 int ret = in_data ? readData(msg_bytes) : readHeader(msg_bytes);
432 msg_bytes = msg_bytes.subspan(
ret);
443 bool ShouldReconnectV1() const noexcept
override {
return false; }
452 static constexpr std::array<std::byte, 0> VERSION_CONTENTS = {};
456 static constexpr
size_t V1_PREFIX_LEN = 16;
587 std::vector<uint8_t> m_recv_buffer
GUARDED_BY(m_recv_mutex);
589 std::vector<uint8_t> m_recv_aad
GUARDED_BY(m_recv_mutex);
591 std::vector<uint8_t> m_recv_decode_buffer
GUARDED_BY(m_recv_mutex);
593 RecvState m_recv_state
GUARDED_BY(m_recv_mutex);
599 std::vector<uint8_t> m_send_buffer
GUARDED_BY(m_send_mutex);
603 std::vector<uint8_t> m_send_garbage
GUARDED_BY(m_send_mutex);
605 std::string m_send_type
GUARDED_BY(m_send_mutex);
607 SendState m_send_state
GUARDED_BY(m_send_mutex);
609 bool m_sent_v1_header_worth
GUARDED_BY(m_send_mutex) {
false};
631 static constexpr uint32_t MAX_GARBAGE_LEN = 4095;
662 std::unique_ptr<i2p::sam::Session> i2p_sam_session =
nullptr;
663 bool prefer_evict =
false;
665 bool use_v2transport =
false;
686 std::shared_ptr<Sock> m_sock
GUARDED_BY(m_sock_mutex);
693 std::deque<CSerializedNetMsg> vSendMsg
GUARDED_BY(cs_vSend);
700 std::atomic<std::chrono::seconds> m_last_send{0s};
701 std::atomic<std::chrono::seconds> m_last_recv{0s};
713 std::atomic<int> nVersion{0};
720 const bool m_prefer_evict{
false};
725 std::atomic_bool fSuccessfullyConnected{
false};
728 std::atomic_bool fDisconnect{
false};
730 std::atomic<int> nRefCount{0};
733 std::atomic_bool fPauseRecv{
false};
734 std::atomic_bool fPauseSend{
false};
739 void MarkReceivedMsgsForProcessing()
751 void AccountForSentBytes(const
std::
string& msg_type,
size_t sent_bytes)
754 mapSendBytesPerMsgType[msg_type] += sent_bytes;
758 switch (m_conn_type) {
782 switch (m_conn_type) {
813 switch (m_conn_type) {
837 Network ConnectedThroughNetwork()
const;
840 [[nodiscard]]
bool IsConnectedThroughPrivacyNet()
const;
843 std::atomic<bool> m_bip152_highbandwidth_to{
false};
845 std::atomic<bool> m_bip152_highbandwidth_from{
false};
848 std::atomic_bool m_has_all_wanted_services{
false};
852 std::atomic_bool m_relays_txs{
false};
856 std::atomic_bool m_bloom_filter_loaded{
false};
863 std::atomic<std::chrono::seconds> m_last_block_time{0s};
869 std::atomic<std::chrono::seconds> m_last_tx_time{0s};
872 std::atomic<std::chrono::microseconds> m_last_ping_time{0us};
876 std::atomic<std::chrono::microseconds> m_min_ping_time{std::chrono::microseconds::max()};
879 std::shared_ptr<Sock> sock,
881 uint64_t nKeyedNetGroupIn,
882 uint64_t nLocalHostNonceIn,
884 const std::string& addrNameIn,
896 return nLocalHostNonce;
919 m_greatest_common_version = greatest_common_version;
923 return m_greatest_common_version;
949 m_last_ping_time = ping_time;
950 m_min_ping_time = std::min(m_min_ping_time.load(), ping_time);
962 std::list<CNetMessage> m_msg_process_queue
GUARDED_BY(m_msg_process_queue_mutex);
963 size_t m_msg_process_queue_size
GUARDED_BY(m_msg_process_queue_mutex){0};
982 std::unique_ptr<i2p::sam::Session> m_i2p_sam_session
GUARDED_BY(m_sock_mutex);
998 virtual void FinalizeNode(
const CNode&
node) = 0;
1004 virtual bool HasAllDesirableServiceFlags(
ServiceFlags services)
const = 0;
1039 int m_max_automatic_connections = 0;
1043 unsigned int nSendBufferMaxSize = 0;
1044 unsigned int nReceiveFloodSize = 0;
1045 uint64_t nMaxOutboundLimit = 0;
1056 bool m_use_addrman_outgoing =
true;
1068 nLocalServices = connOptions.nLocalServices;
1069 m_max_automatic_connections = connOptions.m_max_automatic_connections;
1072 m_max_automatic_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + m_max_feeler;
1073 m_max_inbound = std::max(0, m_max_automatic_connections - m_max_automatic_outbound);
1074 m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing;
1075 m_client_interface = connOptions.uiInterface;
1076 m_banman = connOptions.m_banman;
1077 m_msgproc = connOptions.m_msgproc;
1078 nSendBufferMaxSize = connOptions.nSendBufferMaxSize;
1079 nReceiveFloodSize = connOptions.nReceiveFloodSize;
1080 m_peer_connect_timeout = std::chrono::seconds{connOptions.m_peer_connect_timeout};
1082 LOCK(m_total_bytes_sent_mutex);
1083 nMaxOutboundLimit = connOptions.nMaxOutboundLimit;
1085 vWhitelistedRangeIncoming = connOptions.vWhitelistedRangeIncoming;
1086 vWhitelistedRangeOutgoing = connOptions.vWhitelistedRangeOutgoing;
1088 LOCK(m_added_nodes_mutex);
1091 const bool use_v2transport(GetLocalServices() &
NODE_P2P_V2);
1092 for (
const std::string& added_node : connOptions.m_added_nodes) {
1093 m_added_node_params.push_back({added_node, use_v2transport});
1096 m_onion_binds = connOptions.onion_binds;
1097 whitelist_forcerelay = connOptions.whitelist_forcerelay;
1098 whitelist_relay = connOptions.whitelist_relay;
1102 const CChainParams& params,
bool network_active =
true);
1117 bool GetNetworkActive()
const {
return fNetworkActive; };
1119 void SetNetworkActive(
bool active);
1121 bool CheckIncomingNonce(uint64_t
nonce);
1122 void ASMapHealthCheck();
1134 LOCK(m_nodes_mutex);
1135 for (
auto&&
node : m_nodes) {
1136 if (NodeFullyConnected(
node))
1143 LOCK(m_nodes_mutex);
1144 for (
auto&&
node : m_nodes) {
1145 if (NodeFullyConnected(
node))
1159 std::vector<CAddress> GetAddresses(
size_t max_addresses,
size_t max_pct, std::optional<Network> network,
const bool filtered =
true)
const;
1166 std::vector<CAddress> GetAddresses(
CNode& requestor,
size_t max_addresses,
size_t max_pct);
1170 void SetTryNewOutboundPeer(
bool flag);
1171 bool GetTryNewOutboundPeer()
const;
1173 void StartExtraBlockRelayPeers();
1176 int GetFullOutboundConnCount()
const;
1183 int GetExtraFullOutboundCount()
const;
1185 int GetExtraBlockRelayCount()
const;
1190 std::vector<AddedNodeInfo> GetAddedNodeInfo(
bool include_connected)
const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
1208 std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses()
const;
1209 uint32_t GetMappedAS(
const CNetAddr& addr)
const;
1210 void GetNodeStats(std::vector<CNodeStats>& vstats)
const;
1211 bool DisconnectNode(
const std::string&
node);
1212 bool DisconnectNode(
const CSubNet& subnet);
1213 bool DisconnectNode(
const CNetAddr& addr);
1214 bool DisconnectNode(
NodeId id);
1230 std::chrono::seconds GetMaxOutboundTimeframe() const;
1235 bool OutboundTargetReached(
bool historicalBlockServingLimit) const
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
1243 uint64_t GetTotalBytesRecv() const;
1247 CSipHasher GetDeterministicRandomizer(uint64_t
id) const;
1252 bool ShouldRunInactivityChecks(const
CNode&
node,
std::chrono::seconds now) const;
1262 : sock{sock_}, m_permissions{permissions_}
1276 bool InitBinds(const
Options& options);
1278 void ThreadOpenAddedConnections()
EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_unused_i2p_sessions_mutex, !m_reconnections_mutex);
1281 void ThreadOpenConnections(
std::vector<
std::
string> connect)
EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex, !m_added_nodes_mutex, !m_nodes_mutex, !m_unused_i2p_sessions_mutex, !m_reconnections_mutex);
1283 void ThreadI2PAcceptIncoming();
1284 void AcceptConnection(const
ListenSocket& hListenSocket);
1294 void CreateNodeFromAcceptedSocket(
std::unique_ptr<
Sock>&& sock,
1300 void NotifyNumConnectionsChanged();
1302 bool InactivityCheck(const
CNode&
node) const;
1309 Sock::EventsPerSock GenerateWaitSockets(
Span<
CNode* const> nodes);
1321 void SocketHandlerConnected(const
std::vector<
CNode*>& nodes,
1322 const
Sock::EventsPerSock& events_per_sock)
1329 void SocketHandlerListening(const
Sock::EventsPerSock& events_per_sock);
1331 void ThreadSocketHandler()
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc, !m_nodes_mutex, !m_reconnections_mutex);
1334 uint64_t CalculateKeyedNetGroup(const
CAddress& ad) const;
1337 CNode* FindNode(const
std::
string& addrName);
1344 bool AlreadyConnectedToAddress(const
CAddress& addr);
1346 bool AttemptToEvictConnection();
1350 void DeleteNode(
CNode* pnode);
1357 void DumpAddresses();
1360 void RecordBytesRecv(uint64_t bytes);
1367 std::unordered_set<
Network> GetReachableEmptyNetworks() const;
1372 std::vector<
CAddress> GetCurrentBlockRelayOnlyConns() const;
1384 bool MaybePickPreferredNetwork(
std::optional<
Network>& network);
1387 static
bool NodeFullyConnected(const
CNode* pnode);
1389 uint16_t GetDefaultPort(
Network net) const;
1390 uint16_t GetDefaultPort(const
std::
string& addr) const;
1394 std::atomic<uint64_t> nTotalBytesRecv{0};
1395 uint64_t nTotalBytesSent
GUARDED_BY(m_total_bytes_sent_mutex) {0};
1398 uint64_t nMaxOutboundTotalBytesSentInCycle
GUARDED_BY(m_total_bytes_sent_mutex) {0};
1399 std::chrono::seconds nMaxOutboundCycleStartTime
GUARDED_BY(m_total_bytes_sent_mutex) {0};
1400 uint64_t nMaxOutboundLimit
GUARDED_BY(m_total_bytes_sent_mutex);
1411 unsigned int nSendBufferMaxSize{0};
1412 unsigned int nReceiveFloodSize{0};
1415 std::atomic<bool> fNetworkActive{
true};
1416 bool fAddressesInitialized{
false};
1419 std::deque<std::string> m_addr_fetches
GUARDED_BY(m_addr_fetches_mutex);
1423 std::vector<AddedNodeParams> m_added_node_params
GUARDED_BY(m_added_nodes_mutex);
1426 std::vector<CNode*> m_nodes
GUARDED_BY(m_nodes_mutex);
1429 std::atomic<NodeId> nLastNodeId{0};
1430 unsigned int nPrevNodeCount{0};
1433 std::array<unsigned int, Network::NET_MAX> m_network_conn_counts
GUARDED_BY(m_nodes_mutex) = {};
1443 std::chrono::microseconds m_cache_entry_expiration{0};
1522 std::atomic<bool> flagInterruptMsgProc{
false};
1555 std::atomic_bool m_start_extra_block_relay_peers{
false};
1587 std::queue<std::unique_ptr<i2p::sam::Session>> m_unused_i2p_sessions
GUARDED_BY(m_unused_i2p_sessions_mutex);
1607 std::list<ReconnectionInfo> m_reconnections
GUARDED_BY(m_reconnections_mutex);
1616 static constexpr
size_t MAX_UNUSED_I2P_SESSIONS_SIZE{10};
1629 m_nodes_copy = connman.m_nodes;
1630 for (
auto&
node : m_nodes_copy) {
1641 for (
auto&
node : m_nodes_copy) {
1646 const std::vector<CNode*>&
Nodes()
const 1648 return m_nodes_copy;
1661 extern std::function<void(
const CAddress& addr,
1662 const std::string& msg_type,
1667 #endif // BITCOIN_NET_H static Mutex g_msgproc_mutex
Mutex for anything that is only accessed via the msg processing thread.
std::chrono::microseconds m_min_ping_time
std::vector< CService > vBinds
std::vector< CAddress > m_addrs_response_cache
static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS
Maximum number of block-relay-only outgoing connections.
Mutex m_send_mutex
Lock for sending state.
const std::string m_dest
The pszDest argument provided to ConnectNode().
AddrFetch connections are short lived connections used to solicit addresses from peers.
CNetMessage(DataStream &&recv_in)
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH
Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable).
BIP324Cipher m_cipher
Cipher state.
bool m_i2p_accept_incoming
size_t m_bytes_sent GUARDED_BY(m_send_mutex)
How many bytes have been sent so far (from m_header_to_send, or from m_message_to_send.data).
mapMsgTypeSize mapSendBytesPerMsgType
static void AddFlag(NetPermissionFlags &flags, NetPermissionFlags f)
ServiceFlags
nServices flags
CClientUIInterface uiInterface
Inbound connections are those initiated by a peer.
Unencrypted, plaintext protocol.
Feeler connections are short-lived connections made to check that a node is alive.
std::shared_ptr< Sock > sock
bool m_sending_header GUARDED_BY(m_send_mutex)
Whether we're currently sending header bytes or message bytes.
std::list< CNode * > m_nodes_disconnected
size_t m_send_memusage GUARDED_BY(cs_vSend)
Sum of GetMemoryUsage of all vSendMsg entries.
const uint64_t nKeyedNetGroup
bool SeenLocal(const CService &addr)
vote for a local address
constexpr bool DEFAULT_WHITELISTRELAY
Default for -whitelistrelay.
std::map< std::string, uint64_t > mapMsgTypeSize
int m_max_automatic_outbound
bool IsOutboundOrBlockRelayConn() const
const std::chrono::seconds m_connected
Unix epoch time at peer connection.
int m_max_automatic_connections
Maximum number of automatic connections permitted, excluding manual connections but including inbound...
std::vector< unsigned char > data
const ConnectionType m_conn_type
uint32_t m_send_pos GUARDED_BY(m_send_mutex)
How many bytes from the send buffer have been sent so far.
bool IsFeelerConn() const
int m_max_outbound_full_relay
std::vector< CService > m_onion_binds
A vector of -bind=<address>:<port>=onion arguments each of which is an address and port that are desi...
DataStream hdrbuf GUARDED_BY(m_recv_mutex)
static const bool DEFAULT_LISTEN
-listen default
RAII-style semaphore lock.
void SetCommonVersion(int greatest_common_version)
static const int MAX_ADDNODE_CONNECTIONS
Maximum number of addnode outgoing nodes.
void AddLocalServices(ServiceFlags services)
Updates the local services that this node advertises to other peers during connection handshake...
std::optional< CService > GetLocalAddrForPeer(CNode &node)
Returns a local address that we should advertise to this peer.
Interface for message handling.
static const unsigned char VERSION[]
NetEventsInterface * m_msgproc
const NodeId m_nodeid
NodeId (for debug logging).
CSerializedNetMsg()=default
TransportProtocolType
Transport layer version.
std::atomic< ServiceFlags > nLocalServices
Services this node offers.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
void ForEachNode(const NodeFn &func) const
int m_max_outbound_block_relay
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
std::chrono::seconds m_last_recv
size_t GetMemoryUsage() const noexcept
Compute total memory usage of this object (own memory + any dynamic memory).
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation
uint64_t GetLocalNonce() const
bool m_sent_v1_header_worth GUARDED_BY(m_send_mutex)
Whether we've sent at least 24 bytes (which would trigger disconnect for V1 peers).
V1Transport m_v1_fallback
Encapsulate a V1Transport to fall back to.
ConnectionType m_conn_type
These are the default connections that we use to connect with the network.
DataStream vRecv GUARDED_BY(m_recv_mutex)
uint64_t nSendBytes GUARDED_BY(cs_vSend)
Total number of bytes sent on the wire to this peer.
The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD.
Signals for UI communication.
std::chrono::seconds nMaxOutboundCycleStartTime GUARDED_BY(m_total_bytes_sent_mutex)
static constexpr std::chrono::minutes TIMEOUT_INTERVAL
Time after which to disconnect, after waiting for a ping response (or inactivity).
std::list< CNetMessage > vRecvMsg
SendState
State type that controls the sender side.
std::map< uint64_t, CachedAddrResponse > m_addr_response_caches
Addr responses stored in different caches per (network, local socket) prevent cross-network node iden...
#define ACQUIRED_AFTER(...)
static const int MAX_FEELER_CONNECTIONS
Maximum number of feeler connections.
static bool HasFlag(NetPermissionFlags flags, NetPermissionFlags f)
std::vector< NetWhitelistPermissions > vWhitelistedRangeIncoming
Stochastic address manager.
void AddSocketPermissionFlags(NetPermissionFlags &flags) const
NetPermissionFlags m_permission_flags
Mutex m_unused_i2p_sessions_mutex
Mutex protecting m_i2p_sam_sessions.
TransportProtocolType m_transport_type
Transport protocol type.
std::function< void(const CAddress &addr, const std::string &msg_type, Span< const unsigned char > data, bool is_incoming)> CaptureMessage
Defaults to CaptureMessageToFile(), but can be overridden by unit tests.
std::array< uint8_t, 4 > MessageStartChars
static const size_t DEFAULT_MAXRECEIVEBUFFER
std::thread threadI2PAcceptIncoming
std::tuple< Span< const uint8_t >, bool, const std::string &> BytesToSend
Return type for GetBytesToSend, consisting of:
bool CompleteInternal() const noexcept EXCLUSIVE_LOCKS_REQUIRED(m_recv_mutex)
DataStream m_recv
received message data
CService GetLocalAddress(const CNode &peer)
CSerializedNetMsg Copy() const
std::optional< uint256 > session_id
ListenSocket(std::shared_ptr< Sock > sock_, NetPermissionFlags permissions_)
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it)
constexpr bool DEFAULT_WHITELISTFORCERELAY
Default for -whitelistforcerelay.
std::condition_variable condMsgProc
const std::unique_ptr< Transport > m_transport
Transport serializer/deserializer.
std::chrono::seconds m_connected
bool IsManualOrFullOutboundConn() const
Mutex m_added_nodes_mutex
GlobalMutex g_maplocalhost_mutex
We open manual connections to addresses that users explicitly requested via the addnode RPC or the -a...
std::thread threadOpenAddedConnections
std::string ConnectionTypeAsString(ConnectionType conn_type)
Convert ConnectionType enum to a string value.
Double ended buffer combining vector and stream-like interfaces.
std::vector< NetWhitelistPermissions > vWhitelistedRangeIncoming
std::function< void(CNode *)> NodeFn
TransportProtocolType transport_type
A combination of a network address (CNetAddr) and a (TCP) port.
Transport protocol agnostic message container.
bool whitelist_forcerelay
flag for adding 'forcerelay' permission to whitelisted inbound and manual peers with default permissi...
std::vector< std::string > vSeedNodes
std::vector< std::string > m_specified_outgoing
bool m_bip152_highbandwidth_from
uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(m_total_bytes_sent_mutex)
std::unique_ptr< CSemaphore > semOutbound
std::thread threadMessageHandler
void RemoveLocalServices(ServiceFlags services)
static const int NUM_FDS_MESSAGE_CAPTURE
Number of file descriptors required for message capture.
bool IsManualConn() const
std::chrono::microseconds m_last_ping_time
A CService with information about it as peer.
std::chrono::seconds m_last_tx_time
static constexpr bool DEFAULT_FIXEDSEEDS
std::map< CNetAddr, LocalServiceInfo > mapLocalHost GUARDED_BY(g_maplocalhost_mutex)
static CService ip(uint32_t i)
bool m_bip152_highbandwidth_to
bool ExpectServicesFromConn() const
std::atomic_bool m_try_another_outbound_peer
flag for deciding to connect to an extra outbound peer, in excess of m_max_outbound_full_relay This t...
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS
The maximum number of peer connections to maintain.
static constexpr bool DEFAULT_V2_TRANSPORT
static constexpr bool DEFAULT_DNSSEED
const CChainParams & m_params
Mutex m_recv_mutex
Lock for receive state.
const bool m_initiating
Whether we are the initiator side.
const NetPermissionFlags m_permission_flags
std::chrono::seconds m_last_send
const bool m_inbound_onion
Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
void PongReceived(std::chrono::microseconds ping_time)
A ping-pong round trip has completed successfully.
A helper class for interruptible sleeps.
mapMsgTypeSize mapRecvBytesPerMsgType
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
#define Assume(val)
Assume is the identity function.
uint64_t nRecvBytes GUARDED_BY(cs_vRecv)
RecursiveMutex m_nodes_mutex
const size_t m_recv_flood_size
void Discover()
Look up IP addresses from all interfaces on the machine and add them to the list of local addresses t...
static constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL
Interval for ASMap Health Check.
std::unique_ptr< i2p::sam::Session > m_i2p_sam_session
I2P SAM session.
NetPermissionFlags m_permissions
bool IsBlockOnlyConn() const
Mutex m_addr_fetches_mutex
void RemoveLocal(const CService &addr)
std::vector< CService > onion_binds
#define EXCLUSIVE_LOCKS_REQUIRED(...)
The Transport converts one connection's sent messages to wire bytes, and received bytes back...
BanMan * m_banman
Pointer to this node's banman.
static const size_t DEFAULT_MAXSENDBUFFER
std::thread threadOpenConnections
std::chrono::seconds m_peer_connect_timeout
CSemaphoreGrant grantOutbound
std::thread threadDNSAddressSeed
#define ACQUIRED_BEFORE(...)
std::vector< std::string > m_added_nodes
std::vector< ListenSocket > vhListenSocket
std::vector< NetWhitelistPermissions > vWhitelistedRangeOutgoing
std::chrono::seconds m_last_block_time
static constexpr bool DEFAULT_FORCEDNSSEED
#define AssertLockNotHeld(cs)
std::string m_session_id
BIP324 session id string in hex, if any.
size_t m_msg_process_queue_size GUARDED_BY(m_msg_process_queue_mutex)
static const unsigned int MAX_SUBVERSION_LENGTH
Maximum length of the user agent string in version message.
RecvState
State type that defines the current contents of the receive buffer and/or how the next received bytes...
static constexpr auto FEELER_INTERVAL
Run the feeler connection loop once every 2 minutes.
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT
-peertimeout default
const std::string NET_MESSAGE_TYPE_OTHER
static constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL
Run the extra block-relay-only connection loop once every 5 minutes.
uint64_t nTotalBytesSent GUARDED_BY(m_total_bytes_sent_mutex)
ConnectionType
Different types of connections to a peer.
static const bool DEFAULT_BLOCKSONLY
Default for blocks only.
const uint64_t nLocalHostNonce
Mutex m_msg_process_queue_mutex
RAII helper class that manages a socket and closes it automatically when it goes out of scope...
std::vector< CNode * > m_nodes_copy
Mutex m_reconnections_mutex
Mutex protecting m_reconnections.
bool IsAddrFetchConn() const
RAII helper to atomically create a copy of m_nodes and add a reference to each of the nodes...
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS
Maximum number of automatic outgoing nodes over which we'll relay everything (blocks, tx, addrs, etc)
An encapsulated private key.
A Span is an object that can refer to a contiguous sequence of objects.
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
Different type to mark Mutex at global scope.
NodesSnapshot(const CConnman &connman, bool shuffle)
Information about a peer.
std::thread threadSocketHandler
Simple class for background tasks that should be run periodically or once "after a while"...
Struct for entries in m_reconnections.
std::vector< CAddress > m_anchors
Addresses that were saved during the previous clean shutdown.
const NetGroupManager & m_netgroupman
int GetCommonVersion() const
CSerializedNetMsg & operator=(CSerializedNetMsg &&)=default
const std::string m_addr_name
std::unique_ptr< CSemaphore > semAddnode
CThreadInterrupt interruptNet
This is signaled when network activity should cease.
const MessageStartChars m_magic_bytes
bool ReceivedMessageComplete() const override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex)
Returns true if the current message is complete (so GetReceivedMessage can be called).
bool HasPermission(NetPermissionFlags permission) const
bool AddLocal(const CService &addr, int nScore=LOCAL_NONE)
bool IsInboundConn() const
std::vector< NetWhitebindPermissions > vWhiteBinds
bool whitelist_relay
flag for adding 'relay' permission to whitelisted inbound and manual peers with default permissions...
bool IsLocal(const CService &addr)
check whether a given address is potentially local
uint32_t m_recv_len GUARDED_BY(m_recv_mutex)
In {VERSION, APP}, the decrypted packet length, if m_recv_buffer.size() >= BIP324Cipher::LENGTH_LEN.
const std::vector< CNode * > & Nodes() const
bool GetUseAddrmanOutgoing() const
bool bind_on_any
True if the user did not specify -bind= or -whitebind= and thus we should bind on 0...
bool m_use_addrman_outgoing
Cache responses to addr requests to minimize privacy leak.
bool IsFullOutboundConn() const
We use block-relay-only connections to help prevent against partition attacks.
CClientUIInterface * m_client_interface
static const std::string DEFAULT_MAX_UPLOAD_TARGET
The default for -maxuploadtarget.
std::vector< NetWhitelistPermissions > vWhitelistedRangeOutgoing
std::string cleanSubVer GUARDED_BY(m_subver_mutex)
cleanSubVer is a sanitized string of the user agent byte array we read from the wire.