[#CConnman] = CConnman :mrdocs: Manages all P2P connections: opening, accepting, servicing and tearing them down. == Synopsis Declared in `<net.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CConnman; ---- == Types [cols="1,4"] |=== | Name| Description | xref:CConnman/Options.adoc[`Options`] | Configuration options used to start a CConnman. | xref:CConnman/PrivateBroadcast.adoc[`PrivateBroadcast`] | Group of private broadcast related members. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:CConnman/NodeFn.adoc[`NodeFn`] | Callback type invoked for each node by ForEachNode. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:CConnman/2constructor.adoc[`CConnman`] [.small]#[constructor]# | Construct a connection manager with the given randomness seeds and dependencies. | xref:CConnman/2destructor.adoc[`~CConnman`] [.small]#[destructor]# | Destroy the connection manager, stopping any remaining activity. | xref:CConnman/ASMapHealthCheck.adoc[`ASMapHealthCheck`] | Log a warning if the configured ASMap looks unhealthy. | xref:CConnman/AddConnection.adoc[`AddConnection`] | Attempts to open a connection. Currently only used from tests. | xref:CConnman/AddLocalServices.adoc[`AddLocalServices`] | Updates the local services that this node advertises to other peers during connection handshake. | xref:CConnman/AddNode.adoc[`AddNode`] | Add a manually added node, returning false if it was already present. | xref:CConnman/AddedNodesContain.adoc[`AddedNodesContain`] | Return whether the given address matches one of the manually added nodes. | xref:CConnman/CheckIncomingNonce.adoc[`CheckIncomingNonce`] | Return whether the given nonce differs from every outbound connection's local nonce. | xref:CConnman/DisconnectNode-06.adoc[`DisconnectNode`] | `DisconnectNode` overloads | xref:CConnman/EvictTxPeerIfFull.adoc[`EvictTxPeerIfFull`] | If we are at capacity for inbound tx‐relay peers, attempt to evict one. | xref:CConnman/ForEachNode-03.adoc[`ForEachNode`] | `ForEachNode` overloads | xref:CConnman/ForNode.adoc[`ForNode`] | Invoke a callback on the node with the given id, if it is fully connected. | xref:CConnman/GetAddedNodeInfo.adoc[`GetAddedNodeInfo`] | Return connection info for all manually added nodes. | xref:CConnman/GetAddresses.adoc[`GetAddresses`] | Return addresses from the per‐requestor cache. If no cache entry exists, it is populated with randomly selected addresses. This function can be used in untrusted contexts. | xref:CConnman/GetAddressesUnsafe.adoc[`GetAddressesUnsafe`] | Return randomly selected addresses. This function does not use the address response cache and should only be used in trusted contexts. | xref:CConnman/GetDeterministicRandomizer.adoc[`GetDeterministicRandomizer`] | Get a unique deterministic randomizer. | xref:CConnman/GetExtraBlockRelayCount.adoc[`GetExtraBlockRelayCount`] | Return the number of block‐relay‐only peers we have over our limit. | xref:CConnman/GetExtraFullOutboundCount.adoc[`GetExtraFullOutboundCount`] | Return the number of outbound peers we have in excess of our target. | xref:CConnman/GetFullOutboundConnCount.adoc[`GetFullOutboundConnCount`] | Return the number of full‐relay outbound peers we have. | xref:CConnman/GetLocalServices.adoc[`GetLocalServices`] | Used to convey which local services we are offering peers during node connection. | xref:CConnman/GetMappedAS.adoc[`GetMappedAS`] | Return the autonomous system number the given address maps to. | xref:CConnman/GetMaxOutboundTarget.adoc[`GetMaxOutboundTarget`] | Return the configured maximum number of bytes to upload per cycle (0 = unlimited). | xref:CConnman/GetMaxOutboundTimeLeftInCycle.adoc[`GetMaxOutboundTimeLeftInCycle`] | Return the time left in the current max‐outbound cycle (0 if there is no limit). | xref:CConnman/GetMaxOutboundTimeframe.adoc[`GetMaxOutboundTimeframe`] | Return the length of a max‐outbound cycle. | xref:CConnman/GetNetworkActive.adoc[`GetNetworkActive`] | Return whether networking is currently active. | xref:CConnman/GetNodeCount.adoc[`GetNodeCount`] | Return the number of connections in the given direction (inbound, outbound, or both). | xref:CConnman/GetNodeStats.adoc[`GetNodeStats`] | Collect per‐peer statistics into the given vector. | xref:CConnman/GetNodesMutex.adoc[`GetNodesMutex`] | Return the mutex guarding the node list (for thread‐safety annotations only). | xref:CConnman/GetOutboundTargetBytesLeft.adoc[`GetOutboundTargetBytesLeft`] | response the bytes left in the current max outbound cycle in case of no limit, it will always response 0 | xref:CConnman/GetTotalBytesRecv.adoc[`GetTotalBytesRecv`] | Return the total number of bytes received across all connections. | xref:CConnman/GetTotalBytesSent.adoc[`GetTotalBytesSent`] | Return the total number of bytes sent across all connections. | xref:CConnman/GetTryNewOutboundPeer.adoc[`GetTryNewOutboundPeer`] | Return whether we are currently trying to open an extra outbound peer. | xref:CConnman/GetUseAddrmanOutgoing.adoc[`GetUseAddrmanOutgoing`] | Return whether outgoing peers are selected via the address manager. | xref:CConnman/Init.adoc[`Init`] | Apply the given options to this connection manager. | xref:CConnman/Interrupt.adoc[`Interrupt`] | Interrupt any blocking operations so the manager can shut down. | xref:CConnman/MultipleManualOrFullOutboundConns.adoc[`MultipleManualOrFullOutboundConns`] | Return whether we have more than one manual or full‐relay connection to the given network. | xref:CConnman/OpenNetworkConnection.adoc[`OpenNetworkConnection`] | Open a new P2P connection and initialize it with the PeerManager at `m_msgproc`. | xref:CConnman/OutboundTargetReached.adoc[`OutboundTargetReached`] | check if the outbound target is reached if param historicalBlockServingLimit is set true, the function will response true if the limit for serving historical blocks has been reached | xref:CConnman/PushMessage.adoc[`PushMessage`] | Queue a serialized message to be sent to the given node. | xref:CConnman/RemoveAddedNode.adoc[`RemoveAddedNode`] | Remove a manually added node, returning false if it was not present. | xref:CConnman/RemoveLocalServices.adoc[`RemoveLocalServices`] | Removes service flags from the ones this node advertises to peers. | xref:CConnman/SetCaptureMessages.adoc[`SetCaptureMessages`] | Enable or disable message capture (test only). | xref:CConnman/SetNetworkActive.adoc[`SetNetworkActive`] | Enable or disable networking activity. | xref:CConnman/SetTryNewOutboundPeer.adoc[`SetTryNewOutboundPeer`] | Set whether to try opening an extra outbound peer beyond the normal target. | xref:CConnman/ShouldRunInactivityChecks.adoc[`ShouldRunInactivityChecks`] | Return true if we should disconnect the peer for failing an inactivity check. | xref:CConnman/Start.adoc[`Start`] | Start the connection manager and its worker threads. | xref:CConnman/StartExtraBlockRelayPeers.adoc[`StartExtraBlockRelayPeers`] | Begin opening extra block‐relay‐only peer connections. | xref:CConnman/Stop.adoc[`Stop`] | Stop the connection manager: stop the threads, then the nodes. | xref:CConnman/StopNodes.adoc[`StopNodes`] | Disconnect and delete all nodes. | xref:CConnman/StopThreads.adoc[`StopThreads`] | Stop and join all worker threads. | xref:CConnman/WakeMessageHandler.adoc[`WakeMessageHandler`] | Wake the message handling thread so it processes pending work. | xref:CConnman/getNetLocalAddresses.adoc[`getNetLocalAddresses`] | Return a copy of our known local addresses and their service info. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:CConnman/m_private_broadcast.adoc[`m_private_broadcast`] | Group of private broadcast related members. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:ConnmanTestMsg.adoc[ConnmanTestMsg]` | Test harness that exposes CConnman internals for unit tests. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:EnsureConnman.adoc[`EnsureConnman`] | Get the connection manager from a node context, asserting it is present. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#