[#CConnman]
= CConnman
:mrdocs:

Manages all P2P connections&colon; opening, accepting, servicing and tearing them down&period;

== Synopsis

Declared in `&lt;net&period;h&gt;`

[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&period;
| xref:CConnman/PrivateBroadcast.adoc[`PrivateBroadcast`] 
| Group of private broadcast related members&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:CConnman/NodeFn.adoc[`NodeFn`] 
| Callback type invoked for each node by ForEachNode&period;
|===


== 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&period;
| xref:CConnman/2destructor.adoc[`&#126;CConnman`] [.small]#[destructor]#
| Destroy the connection manager, stopping any remaining activity&period;
| xref:CConnman/ASMapHealthCheck.adoc[`ASMapHealthCheck`] 
| Log a warning if the configured ASMap looks unhealthy&period;
| xref:CConnman/AddConnection.adoc[`AddConnection`] 
| Attempts to open a connection&period; Currently only used from tests&period;
| xref:CConnman/AddLocalServices.adoc[`AddLocalServices`] 
| Updates the local services that this node advertises to other peers during connection handshake&period;
| xref:CConnman/AddNode.adoc[`AddNode`] 
| Add a manually added node, returning false if it was already present&period;
| xref:CConnman/AddedNodesContain.adoc[`AddedNodesContain`] 
| Return whether the given address matches one of the manually added nodes&period;
| xref:CConnman/CheckIncomingNonce.adoc[`CheckIncomingNonce`] 
| Return whether the given nonce differs from every outbound connection&apos;s local nonce&period;
| xref:CConnman/DisconnectNode-06.adoc[`DisconnectNode`] 
| `DisconnectNode` overloads
| xref:CConnman/EvictTxPeerIfFull.adoc[`EvictTxPeerIfFull`] 
| If we are at capacity for inbound tx&hyphen;relay peers, attempt to evict one&period;
| 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&period;
| xref:CConnman/GetAddedNodeInfo.adoc[`GetAddedNodeInfo`] 
| Return connection info for all manually added nodes&period;
| xref:CConnman/GetAddresses.adoc[`GetAddresses`] 
| Return addresses from the per&hyphen;requestor cache&period; If no cache entry exists, it is populated with randomly selected addresses&period; This function can be used in untrusted contexts&period;
| xref:CConnman/GetAddressesUnsafe.adoc[`GetAddressesUnsafe`] 
| Return randomly selected addresses&period; This function does not use the address response cache and should only be used in trusted contexts&period;
| xref:CConnman/GetDeterministicRandomizer.adoc[`GetDeterministicRandomizer`] 
| Get a unique deterministic randomizer&period;
| xref:CConnman/GetExtraBlockRelayCount.adoc[`GetExtraBlockRelayCount`] 
| Return the number of block&hyphen;relay&hyphen;only peers we have over our limit&period;
| xref:CConnman/GetExtraFullOutboundCount.adoc[`GetExtraFullOutboundCount`] 
| Return the number of outbound peers we have in excess of our target&period;
| xref:CConnman/GetFullOutboundConnCount.adoc[`GetFullOutboundConnCount`] 
| Return the number of full&hyphen;relay outbound peers we have&period;
| xref:CConnman/GetLocalServices.adoc[`GetLocalServices`] 
| Used to convey which local services we are offering peers during node connection&period;
| xref:CConnman/GetMappedAS.adoc[`GetMappedAS`] 
| Return the autonomous system number the given address maps to&period;
| xref:CConnman/GetMaxOutboundTarget.adoc[`GetMaxOutboundTarget`] 
| Return the configured maximum number of bytes to upload per cycle (0 &equals; unlimited)&period;
| xref:CConnman/GetMaxOutboundTimeLeftInCycle.adoc[`GetMaxOutboundTimeLeftInCycle`] 
| Return the time left in the current max&hyphen;outbound cycle (0 if there is no limit)&period;
| xref:CConnman/GetMaxOutboundTimeframe.adoc[`GetMaxOutboundTimeframe`] 
| Return the length of a max&hyphen;outbound cycle&period;
| xref:CConnman/GetNetworkActive.adoc[`GetNetworkActive`] 
| Return whether networking is currently active&period;
| xref:CConnman/GetNodeCount.adoc[`GetNodeCount`] 
| Return the number of connections in the given direction (inbound, outbound, or both)&period;
| xref:CConnman/GetNodeStats.adoc[`GetNodeStats`] 
| Collect per&hyphen;peer statistics into the given vector&period;
| xref:CConnman/GetNodesMutex.adoc[`GetNodesMutex`] 
| Return the mutex guarding the node list (for thread&hyphen;safety annotations only)&period;
| 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&period;
| xref:CConnman/GetTotalBytesSent.adoc[`GetTotalBytesSent`] 
| Return the total number of bytes sent across all connections&period;
| xref:CConnman/GetTryNewOutboundPeer.adoc[`GetTryNewOutboundPeer`] 
| Return whether we are currently trying to open an extra outbound peer&period;
| xref:CConnman/GetUseAddrmanOutgoing.adoc[`GetUseAddrmanOutgoing`] 
| Return whether outgoing peers are selected via the address manager&period;
| xref:CConnman/Init.adoc[`Init`] 
| Apply the given options to this connection manager&period;
| xref:CConnman/Interrupt.adoc[`Interrupt`] 
| Interrupt any blocking operations so the manager can shut down&period;
| xref:CConnman/MultipleManualOrFullOutboundConns.adoc[`MultipleManualOrFullOutboundConns`] 
| Return whether we have more than one manual or full&hyphen;relay connection to the given network&period;
| xref:CConnman/OpenNetworkConnection.adoc[`OpenNetworkConnection`] 
| Open a new P2P connection and initialize it with the PeerManager at `m&lowbar;msgproc`&period;
| 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&period;
| xref:CConnman/RemoveAddedNode.adoc[`RemoveAddedNode`] 
| Remove a manually added node, returning false if it was not present&period;
| xref:CConnman/RemoveLocalServices.adoc[`RemoveLocalServices`] 
| Removes service flags from the ones this node advertises to peers&period;
| xref:CConnman/SetCaptureMessages.adoc[`SetCaptureMessages`] 
| Enable or disable message capture (test only)&period;
| xref:CConnman/SetNetworkActive.adoc[`SetNetworkActive`] 
| Enable or disable networking activity&period;
| xref:CConnman/SetTryNewOutboundPeer.adoc[`SetTryNewOutboundPeer`] 
| Set whether to try opening an extra outbound peer beyond the normal target&period;
| xref:CConnman/ShouldRunInactivityChecks.adoc[`ShouldRunInactivityChecks`] 
| Return true if we should disconnect the peer for failing an inactivity check&period;
| xref:CConnman/Start.adoc[`Start`] 
| Start the connection manager and its worker threads&period;
| xref:CConnman/StartExtraBlockRelayPeers.adoc[`StartExtraBlockRelayPeers`] 
| Begin opening extra block&hyphen;relay&hyphen;only peer connections&period;
| xref:CConnman/Stop.adoc[`Stop`] 
| Stop the connection manager&colon; stop the threads, then the nodes&period;
| xref:CConnman/StopNodes.adoc[`StopNodes`] 
| Disconnect and delete all nodes&period;
| xref:CConnman/StopThreads.adoc[`StopThreads`] 
| Stop and join all worker threads&period;
| xref:CConnman/WakeMessageHandler.adoc[`WakeMessageHandler`] 
| Wake the message handling thread so it processes pending work&period;
| xref:CConnman/getNetLocalAddresses.adoc[`getNetLocalAddresses`] 
| Return a copy of our known local addresses and their service info&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CConnman/m_private_broadcast.adoc[`m&lowbar;private&lowbar;broadcast`] 
| Group of private broadcast related members&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:ConnmanTestMsg.adoc[ConnmanTestMsg]`
| Test harness that exposes CConnman internals for unit tests&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:EnsureConnman.adoc[`EnsureConnman`]
| Get the connection manager from a node context, asserting it is present&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
