libp2p/connmanager

    Dark Mode
Search:
Group by:
  Source   Edit

Types

ConnectionSlot = object
  connManager: ConnManager
  direction: Direction
  Source   Edit
ConnEvent = object
  case kind*: ConnEventKind
  of ConnEventKind.Connected:
      incoming*: bool

  else:
      nil

  
  Source   Edit
ConnEventHandler = proc (peerId: PeerId; event: ConnEvent): Future[void] {.
    ...gcsafe, raises: [].}
  Source   Edit
ConnEventKind {.pure.} = enum
  Connected, Disconnected
  Source   Edit
ConnManager = ref object of RootObj
  maxConnsPerPeer: int
  inSema*: AsyncSemaphore
  outSema*: AsyncSemaphore
  muxed: Table[PeerId, seq[Muxer]]
  connEvents: array[ConnEventKind, OrderedSet[ConnEventHandler]]
  peerEvents: array[PeerEventKind, OrderedSet[PeerEventHandler]]
  expectedConnectionsOverLimit*: Table[Future[Muxer]]
  peerStore*: PeerStore
  Source   Edit
PeerEvent = object
  case kind*: PeerEventKind
  of PeerEventKind.Joined, PeerEventKind.Identified:
      initiator*: bool

  else:
      nil

  
  Source   Edit
PeerEventHandler = proc (peerId: PeerId; event: PeerEvent): Future[void] {.
    ...gcsafe, raises: [].}
  Source   Edit
PeerEventKind {.pure.} = enum
  Left, Joined, Identified
  Source   Edit

Procs

proc addConnEventHandler(c: ConnManager; handler: ConnEventHandler;
                         kind: ConnEventKind) {....raises: [], tags: [].}
Add peer event handler - handlers must not raise exceptions!   Source   Edit
proc addPeerEventHandler(c: ConnManager; handler: PeerEventHandler;
                         kind: PeerEventKind) {....raises: [], tags: [].}
Add peer event handler - handlers must not raise exceptions!   Source   Edit
proc close(c: ConnManager): Future[void] {.stackTrace: false, ...raises: [],
    gcsafe, raises: [], raises: [], tags: [RootEffect].}
cleanup resources for the connection manager   Source   Edit
proc connCount(c: ConnManager; peerId: PeerId): int {....raises: [], tags: [].}
  Source   Edit
proc contains(c: ConnManager; muxer: Muxer): bool {....raises: [], tags: [].}
checks if a muxer is being tracked by the connection manager   Source   Edit
proc contains(c: ConnManager; peerId: PeerId): bool {....raises: [], tags: [].}
  Source   Edit
proc dropPeer(c: ConnManager; peerId: PeerId): Future[void] {.stackTrace: false,
    ...raises: [], gcsafe, raises: [], raises: [], tags: [RootEffect].}
drop connections and cleanup resources for peer   Source   Edit
proc expectConnection(c: ConnManager; p: PeerId; dir: Direction): Future[Muxer] {.
    stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
    tags: [RootEffect].}
Wait for a peer to connect to us. This will bypass the MaxConnectionsPerPeer   Source   Edit
proc getConnections(c: ConnManager): Table[PeerId, seq[Muxer]] {....raises: [],
    tags: [].}
  Source   Edit
proc getIncomingSlot(c: ConnManager): Future[ConnectionSlot] {.
    stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
    tags: [RootEffect].}
  Source   Edit
proc getOutgoingSlot(c: ConnManager; forceDial = false): ConnectionSlot {.
    ...raises: [TooManyConnectionsError], raises: [], tags: [].}
  Source   Edit
proc getStream(c: ConnManager; muxer: Muxer): Future[Connection] {.
    stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
    tags: [RootEffect].}
get a muxed stream for the passed muxer   Source   Edit
proc getStream(c: ConnManager; peerId: PeerId): Future[Connection] {.
    stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
    tags: [RootEffect].}
get a muxed stream for the passed peer from any connection   Source   Edit
proc getStream(c: ConnManager; peerId: PeerId; dir: Direction): Future[
    Connection] {.stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
                  tags: [RootEffect].}
get a muxed stream for the passed peer from a connection with dir   Source   Edit
proc new(C: type ConnManager; maxConnsPerPeer = MaxConnectionsPerPeer;
         maxConnections = MaxConnections; maxIn = -1; maxOut = -1): ConnManager {.
    ...raises: [].}
  Source   Edit
proc release(cs: ConnectionSlot) {....raises: [], tags: [].}
  Source   Edit
proc removeConnEventHandler(c: ConnManager; handler: ConnEventHandler;
                            kind: ConnEventKind) {....raises: [], tags: [].}
  Source   Edit
proc removePeerEventHandler(c: ConnManager; handler: PeerEventHandler;
                            kind: PeerEventKind) {....raises: [], tags: [].}
  Source   Edit
proc selectMuxer(c: ConnManager; peerId: PeerId): Muxer {....raises: [], tags: [].}
Select a connection for the provided giving priority to outgoing connections   Source   Edit
proc trackConnection(cs: ConnectionSlot; conn: Connection) {....raises: [],
    tags: [RootEffect].}
  Source   Edit
proc trackMuxer(cs: ConnectionSlot; mux: Muxer) {....raises: [], tags: [RootEffect].}
  Source   Edit
proc triggerPeerEvents(c: ConnManager; peerId: PeerId; event: PeerEvent): Future[
    void] {.stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [],
            tags: [RootEffect].}
  Source   Edit