libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

Network.LibP2P.Switch.Types

Description

Core types for the libp2p Switch (central coordinator).

Defines connection states, direction, muxer session abstraction, connection records, switch events, and the Switch itself. See docs/08-switch.md for the full specification.

Synopsis

Documentation

data ConnState Source #

Connection state machine (docs/08-switch.md §Connection States).

Connecting → ConnOpen → Closing → Closed

Constructors

Connecting

Raw transport established, upgrade in progress

ConnOpen

Fully upgraded, streams can be opened/accepted

Closing

Go Away sent/received, draining existing streams

ConnClosed

Transport connection closed, resources freed

Instances

Instances details
Show ConnState Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

Eq ConnState Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

data Direction Source #

Direction of a connection relative to this node. Defined here to avoid circular dependency with Switch.Types.

Constructors

Inbound

Remote peer initiated the connection

Outbound

Local node initiated the connection

Instances

Instances details
Show Direction Source # 
Instance details

Defined in Network.LibP2P.Switch.ResourceManager

Eq Direction Source # 
Instance details

Defined in Network.LibP2P.Switch.ResourceManager

data MuxerSession Source #

Abstract muxer session interface.

Decouples Switch from a specific muxer (Yamux, mplex, etc.). Each muxer implementation provides a MuxerSession adapter.

Constructors

MuxerSession 

Fields

data Connection Source #

An upgraded (secure + multiplexed) connection to a remote peer.

Constructors

Connection 

Fields

data SwitchEvent Source #

Events emitted by the Switch for observability.

Constructors

Connected !PeerId !Direction !Multiaddr

Connection fully upgraded

Disconnected !PeerId !Direction !Multiaddr

Connection closed

Instances

Instances details
Show SwitchEvent Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

Eq SwitchEvent Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

type StreamHandler = StreamIO -> PeerId -> IO () Source #

A protocol stream handler.

Receives the stream I/O and the remote peer's identity.

data Switch Source #

The Switch: central coordinator of the libp2p networking stack.

Manages transports, connection pool, protocol handlers, and events. All mutable state is STM-based for safe concurrent access.

Constructors

Switch 

Fields

data DialError Source #

Errors that can occur during a dial operation (docs/08-switch.md §Dialing).

Constructors

DialBackoff

Peer is in backoff period (recently failed)

DialNoAddresses

No addresses provided for dialing

DialNoTransport !Multiaddr

No registered transport can handle this address

DialAllFailed ![String]

All dial attempts failed

DialUpgradeFailed !String

Connection upgrade pipeline failed

DialSwitchClosed

Switch has been shut down

DialResourceLimit !ResourceError

Resource limit exceeded

DialPeerIdMismatch !PeerId !PeerId

Expected vs actual remote PeerId

Instances

Instances details
Show DialError Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

Eq DialError Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

data BackoffEntry Source #

Per-peer dial backoff state (docs/08-switch.md §Dial Backoff).

After a failed dial, subsequent dials are rejected until the backoff expires. Duration doubles on each consecutive failure up to 300s max.

Constructors

BackoffEntry 

Fields

Instances

Instances details
Show BackoffEntry Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

Eq BackoffEntry Source # 
Instance details

Defined in Network.LibP2P.Switch.Types

data ResourceError Source #

Resource limit violation error.

data ActiveListener Source #

An active listener bound to an address with its accept loop thread.

Constructors

ActiveListener 

Fields