35 #include <condition_variable> 45 #include <unordered_set> 132 std::vector<unsigned char>
data;
237 std::chrono::microseconds m_time{0};
238 uint32_t m_message_size{0};
239 uint32_t m_raw_message_size{0};
276 virtual
bool ReceivedMessageComplete() const = 0;
284 virtual
bool ReceivedBytes(
Span<const uint8_t>& msg_bytes) = 0;
293 virtual
CNetMessage GetReceivedMessage(
std::chrono::microseconds time,
bool& reject_message) = 0;
313 Span<const uint8_t> ,
353 virtual
BytesToSend GetBytesToSend(
bool have_next_message) const noexcept = 0;
361 virtual
void MarkBytesSent(
size_t bytes_sent) noexcept = 0;
364 virtual
size_t GetSendMemoryUsage() const noexcept = 0;
369 virtual
bool ShouldReconnectV1() const noexcept = 0;
384 unsigned int nHdrPos
GUARDED_BY(m_recv_mutex);
385 unsigned int nDataPos
GUARDED_BY(m_recv_mutex);
406 if (!in_data)
return false;
407 return hdr.nMessageSize == nDataPos;
413 std::vector<uint8_t> m_header_to_send
GUARDED_BY(m_send_mutex);
427 return WITH_LOCK(m_recv_mutex,
return CompleteInternal());
430 Info
GetInfo() const noexcept override;
436 int ret = in_data ? readData(msg_bytes) : readHeader(msg_bytes);
440 msg_bytes = msg_bytes.subspan(
ret);
451 bool ShouldReconnectV1() const noexcept
override {
return false; }
460 static constexpr std::array<std::byte, 0> VERSION_CONTENTS = {};
464 static constexpr
size_t V1_PREFIX_LEN = 16;
595 std::vector<uint8_t> m_recv_buffer
GUARDED_BY(m_recv_mutex);
597 std::vector<uint8_t> m_recv_aad
GUARDED_BY(m_recv_mutex);
599 std::vector<uint8_t> m_recv_decode_buffer
GUARDED_BY(m_recv_mutex);
611 std::vector<uint8_t> m_send_buffer
GUARDED_BY(m_send_mutex);
615 std::vector<uint8_t> m_send_garbage
GUARDED_BY(m_send_mutex);
617 std::string m_send_type
GUARDED_BY(m_send_mutex);
619 SendState m_send_state
GUARDED_BY(m_send_mutex);
621 bool m_sent_v1_header_worth
GUARDED_BY(m_send_mutex) {
false};
643 static constexpr uint32_t MAX_GARBAGE_LEN = 4095;
652 V2Transport(
NodeId nodeid,
bool initiating,
int type_in,
int version_in) noexcept;
655 V2Transport(
NodeId nodeid,
bool initiating,
int type_in,
int version_in, const
CKey& key,
Span<const
std::byte> ent32,
std::vector<uint8_t> garbage) noexcept;
676 std::unique_ptr<i2p::sam::Session> i2p_sam_session =
nullptr;
677 bool prefer_evict =
false;
679 bool use_v2transport =
false;
700 std::shared_ptr<Sock> m_sock
GUARDED_BY(m_sock_mutex);
707 std::deque<CSerializedNetMsg> vSendMsg
GUARDED_BY(cs_vSend);
714 std::atomic<std::chrono::seconds> m_last_send{0s};
715 std::atomic<std::chrono::seconds> m_last_recv{0s};
718 std::atomic<int64_t> nTimeOffset{0};
728 std::atomic<int> nVersion{0};
735 const bool m_prefer_evict{
false};
740 std::atomic_bool fSuccessfullyConnected{
false};
743 std::atomic_bool fDisconnect{
false};
745 std::atomic<int> nRefCount{0};
748 std::atomic_bool fPauseRecv{
false};
749 std::atomic_bool fPauseSend{
false};
754 void MarkReceivedMsgsForProcessing()
766 void AccountForSentBytes(const
std::
string& msg_type,
size_t sent_bytes)
769 mapSendBytesPerMsgType[msg_type] += sent_bytes;
773 switch (m_conn_type) {
797 switch (m_conn_type) {
828 switch (m_conn_type) {
852 Network ConnectedThroughNetwork()
const;
855 [[nodiscard]]
bool IsConnectedThroughPrivacyNet()
const;
858 std::atomic<bool> m_bip152_highbandwidth_to{
false};
860 std::atomic<bool> m_bip152_highbandwidth_from{
false};
863 std::atomic_bool m_has_all_wanted_services{
false};
867 std::atomic_bool m_relays_txs{
false};
871 std::atomic_bool m_bloom_filter_loaded{
false};
878 std::atomic<std::chrono::seconds> m_last_block_time{0s};
884 std::atomic<std::chrono::seconds> m_last_tx_time{0s};
887 std::atomic<std::chrono::microseconds> m_last_ping_time{0us};
891 std::atomic<std::chrono::microseconds> m_min_ping_time{std::chrono::microseconds::max()};
894 std::shared_ptr<Sock> sock,
896 uint64_t nKeyedNetGroupIn,
897 uint64_t nLocalHostNonceIn,
899 const std::string& addrNameIn,
911 return nLocalHostNonce;
934 m_greatest_common_version = greatest_common_version;
938 return m_greatest_common_version;
964 m_last_ping_time = ping_time;
965 m_min_ping_time = std::min(m_min_ping_time.load(), ping_time);
977 std::list<CNetMessage> m_msg_process_queue
GUARDED_BY(m_msg_process_queue_mutex);
978 size_t m_msg_process_queue_size
GUARDED_BY(m_msg_process_queue_mutex){0};
997 std::unique_ptr<i2p::sam::Session> m_i2p_sam_session
GUARDED_BY(m_sock_mutex);
1013 virtual void FinalizeNode(
const CNode&
node) = 0;
1048 int nMaxConnections = 0;
1049 int m_max_outbound_full_relay = 0;
1050 int m_max_outbound_block_relay = 0;
1051 int nMaxAddnode = 0;
1056 unsigned int nSendBufferMaxSize = 0;
1057 unsigned int nReceiveFloodSize = 0;
1058 uint64_t nMaxOutboundLimit = 0;
1068 bool m_use_addrman_outgoing =
true;
1078 nLocalServices = connOptions.nLocalServices;
1079 nMaxConnections = connOptions.nMaxConnections;
1080 m_max_outbound_full_relay = std::min(connOptions.m_max_outbound_full_relay, connOptions.nMaxConnections);
1081 m_max_outbound_block_relay = connOptions.m_max_outbound_block_relay;
1082 m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing;
1083 nMaxAddnode = connOptions.nMaxAddnode;
1084 nMaxFeeler = connOptions.nMaxFeeler;
1085 m_max_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler;
1086 m_client_interface = connOptions.uiInterface;
1087 m_banman = connOptions.m_banman;
1088 m_msgproc = connOptions.m_msgproc;
1089 nSendBufferMaxSize = connOptions.nSendBufferMaxSize;
1090 nReceiveFloodSize = connOptions.nReceiveFloodSize;
1091 m_peer_connect_timeout = std::chrono::seconds{connOptions.m_peer_connect_timeout};
1093 LOCK(m_total_bytes_sent_mutex);
1094 nMaxOutboundLimit = connOptions.nMaxOutboundLimit;
1096 vWhitelistedRange = connOptions.vWhitelistedRange;
1098 LOCK(m_added_nodes_mutex);
1100 for (
const std::string& added_node : connOptions.m_added_nodes) {
1102 m_added_node_params.push_back({added_node,
false});
1105 m_onion_binds = connOptions.onion_binds;
1109 const CChainParams& params,
bool network_active =
true);
1124 bool GetNetworkActive()
const {
return fNetworkActive; };
1126 void SetNetworkActive(
bool active);
1128 bool CheckIncomingNonce(uint64_t
nonce);
1140 LOCK(m_nodes_mutex);
1141 for (
auto&&
node : m_nodes) {
1142 if (NodeFullyConnected(
node))
1149 LOCK(m_nodes_mutex);
1150 for (
auto&&
node : m_nodes) {
1151 if (NodeFullyConnected(
node))
1164 std::vector<CAddress> GetAddresses(
size_t max_addresses,
size_t max_pct, std::optional<Network> network)
const;
1171 std::vector<CAddress> GetAddresses(
CNode& requestor,
size_t max_addresses,
size_t max_pct);
1175 void SetTryNewOutboundPeer(
bool flag);
1176 bool GetTryNewOutboundPeer()
const;
1178 void StartExtraBlockRelayPeers();
1186 int GetExtraFullOutboundCount()
const;
1188 int GetExtraBlockRelayCount()
const;
1210 uint32_t GetMappedAS(const
CNetAddr& addr) const;
1212 bool DisconnectNode(const
std::
string&
node);
1213 bool DisconnectNode(const
CSubNet& subnet);
1214 bool DisconnectNode(const
CNetAddr& addr);
1215 bool DisconnectNode(
NodeId id);
1226 std::chrono::seconds GetMaxOutboundTimeframe() const;
1231 bool OutboundTargetReached(
bool historicalBlockServingLimit) const
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
1239 uint64_t GetTotalBytesRecv() const;
1243 CSipHasher GetDeterministicRandomizer(uint64_t
id) const;
1248 bool ShouldRunInactivityChecks(const
CNode&
node,
std::chrono::seconds now) const;
1258 : sock{sock_}, m_permissions{permissions_}
1272 bool InitBinds(const
Options& options);
1274 void ThreadOpenAddedConnections()
EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_unused_i2p_sessions_mutex, !m_reconnections_mutex);
1277 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);
1279 void ThreadI2PAcceptIncoming();
1280 void AcceptConnection(const
ListenSocket& hListenSocket);
1290 void CreateNodeFromAcceptedSocket(
std::unique_ptr<
Sock>&& sock,
1296 void NotifyNumConnectionsChanged();
1298 bool InactivityCheck(const
CNode&
node) const;
1305 Sock::EventsPerSock GenerateWaitSockets(
Span<
CNode* const> nodes);
1317 void SocketHandlerConnected(const
std::vector<
CNode*>& nodes,
1318 const
Sock::EventsPerSock& events_per_sock)
1325 void SocketHandlerListening(const
Sock::EventsPerSock& events_per_sock);
1327 void ThreadSocketHandler()
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc, !m_nodes_mutex, !m_reconnections_mutex);
1330 uint64_t CalculateKeyedNetGroup(const
CAddress& ad) const;
1333 CNode* FindNode(const
std::
string& addrName);
1340 bool AlreadyConnectedToAddress(const
CAddress& addr);
1342 bool AttemptToEvictConnection();
1346 void DeleteNode(
CNode* pnode);
1353 void DumpAddresses();
1356 void RecordBytesRecv(uint64_t bytes);
1363 std::unordered_set<
Network> GetReachableEmptyNetworks() const;
1368 std::vector<
CAddress> GetCurrentBlockRelayOnlyConns() const;
1380 bool MaybePickPreferredNetwork(
std::optional<
Network>& network);
1383 static
bool NodeFullyConnected(const
CNode* pnode);
1385 uint16_t GetDefaultPort(
Network net) const;
1386 uint16_t GetDefaultPort(const
std::
string& addr) const;
1390 std::atomic<uint64_t> nTotalBytesRecv{0};
1391 uint64_t nTotalBytesSent
GUARDED_BY(m_total_bytes_sent_mutex) {0};
1394 uint64_t nMaxOutboundTotalBytesSentInCycle
GUARDED_BY(m_total_bytes_sent_mutex) {0};
1395 std::chrono::seconds nMaxOutboundCycleStartTime
GUARDED_BY(m_total_bytes_sent_mutex) {0};
1396 uint64_t nMaxOutboundLimit
GUARDED_BY(m_total_bytes_sent_mutex);
1405 unsigned int nSendBufferMaxSize{0};
1406 unsigned int nReceiveFloodSize{0};
1409 std::atomic<bool> fNetworkActive{
true};
1410 bool fAddressesInitialized{
false};
1413 std::deque<std::string> m_addr_fetches
GUARDED_BY(m_addr_fetches_mutex);
1417 std::vector<AddedNodeParams> m_added_node_params
GUARDED_BY(m_added_nodes_mutex);
1420 std::vector<CNode*> m_nodes
GUARDED_BY(m_nodes_mutex);
1423 std::atomic<NodeId> nLastNodeId{0};
1424 unsigned int nPrevNodeCount{0};
1427 std::array<unsigned int, Network::NET_MAX> m_network_conn_counts
GUARDED_BY(m_nodes_mutex) = {};
1437 std::chrono::microseconds m_cache_entry_expiration{0};
1502 std::atomic<bool> flagInterruptMsgProc{
false};
1535 std::atomic_bool m_start_extra_block_relay_peers{
false};
1555 std::queue<std::unique_ptr<i2p::sam::Session>> m_unused_i2p_sessions
GUARDED_BY(m_unused_i2p_sessions_mutex);
1575 std::list<ReconnectionInfo> m_reconnections
GUARDED_BY(m_reconnections_mutex);
1584 static constexpr
size_t MAX_UNUSED_I2P_SESSIONS_SIZE{10};
1597 m_nodes_copy = connman.m_nodes;
1598 for (
auto&
node : m_nodes_copy) {
1609 for (
auto&
node : m_nodes_copy) {
1614 const std::vector<CNode*>&
Nodes()
const 1616 return m_nodes_copy;
1629 extern std::function<void(
const CAddress& addr,
1630 const std::string& msg_type,
1635 #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.
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
std::map< std::string, uint64_t > mapMsgTypeSize
bool IsOutboundOrBlockRelayConn() const
const std::chrono::seconds m_connected
Unix epoch time at peer connection.
const int m_recv_version
Deserialization version number.
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.
std::vector< NetWhitelistPermissions > vWhitelistedRange
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...
CDataStream m_recv
received message data
static const bool DEFAULT_LISTEN
-listen default
CNetMessage(CDataStream &&recv_in)
RAII-style semaphore lock.
void SetCommonVersion(int greatest_common_version)
static const int MAX_ADDNODE_CONNECTIONS
Maximum number of addnode outgoing nodes.
std::optional< CService > GetLocalAddrForPeer(CNode &node)
Returns a local address that we should advertise to this peer.
Interface for message handling.
void SetVersion(int nVersionIn)
static const unsigned char VERSION[]
NetEventsInterface * m_msgproc
const NodeId m_nodeid
NodeId (for debug logging).
CSerializedNetMsg()=default
TransportProtocolType
Transport layer version.
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).
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.
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)
Stochastic address manager.
void AddSocketPermissionFlags(NetPermissionFlags &flags) const
NetPermissionFlags m_permission_flags
ServiceFlags nLocalServices
Services this node offers.
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)
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)
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.
std::function< void(CNode *)> NodeFn
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation
TransportProtocolType transport_type
A combination of a network address (CNetAddr) and a (TCP) port.
Transport protocol agnostic message container.
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
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...
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< NetWhitelistPermissions > vWhitelistedRange
std::vector< CService > onion_binds
MessageStartChars m_magic_bytes
void Shuffle(I first, I last, R &&rng)
More efficient than using std::shuffle on a FastRandomContext.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
static const bool DEFAULT_WHITELISTFORCERELAY
Default for -whitelistforcerelay.
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::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
static const bool DEFAULT_WHITELISTRELAY
Default for -whitelistrelay.
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.
const int m_recv_type
Deserialization type.
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.
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 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::string cleanSubVer GUARDED_BY(m_subver_mutex)
cleanSubVer is a sanitized string of the user agent byte array we read from the wire.