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

Network.LibP2P.MultistreamSelect.Negotiation

Description

multistream-select protocol negotiation.

Implements Initiator and Responder roles for negotiating which protocol to use over a connection or stream.

Synopsis

Documentation

type ProtocolId = Text Source #

A protocol identifier (e.g. "noise", "yamux/1.0.0").

data StreamIO Source #

Abstraction for stream I/O to enable testing with in-memory buffers.

Constructors

StreamIO 

Fields

negotiateInitiator :: StreamIO -> [ProtocolId] -> IO NegotiationResult Source #

Negotiate as the Initiator. Sends header, then tries each protocol in order until one is accepted.

negotiateResponder :: StreamIO -> [ProtocolId] -> IO NegotiationResult Source #

Negotiate as the Responder. Receives header, then responds to the initiator's proposal.

mkMemoryStreamPair :: IO (StreamIO, StreamIO) Source #

Create an in-memory stream pair for testing using STM TQueue. Writes to stream A appear as reads on stream B and vice versa.