ouroboros-network-framework-0.13.1.0: Ouroboros network framework
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Network.Mux

Synopsis

Basic notions

data WithProtocolTemperature (pt ∷ ProtocolTemperature) a where Source #

We keep hot, warm and established application (or their context) distinct. It's only needed for a handy projectBundle map.

Instances

Instances details
Foldable (WithProtocolTemperature pt) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

foldMonoid m ⇒ WithProtocolTemperature pt m → m #

foldMapMonoid m ⇒ (a → m) → WithProtocolTemperature pt a → m #

foldMap'Monoid m ⇒ (a → m) → WithProtocolTemperature pt a → m #

foldr ∷ (a → b → b) → b → WithProtocolTemperature pt a → b #

foldr' ∷ (a → b → b) → b → WithProtocolTemperature pt a → b #

foldl ∷ (b → a → b) → b → WithProtocolTemperature pt a → b #

foldl' ∷ (b → a → b) → b → WithProtocolTemperature pt a → b #

foldr1 ∷ (a → a → a) → WithProtocolTemperature pt a → a #

foldl1 ∷ (a → a → a) → WithProtocolTemperature pt a → a #

toListWithProtocolTemperature pt a → [a] #

nullWithProtocolTemperature pt a → Bool #

lengthWithProtocolTemperature pt a → Int #

elemEq a ⇒ a → WithProtocolTemperature pt a → Bool #

maximumOrd a ⇒ WithProtocolTemperature pt a → a #

minimumOrd a ⇒ WithProtocolTemperature pt a → a #

sumNum a ⇒ WithProtocolTemperature pt a → a #

productNum a ⇒ WithProtocolTemperature pt a → a #

Traversable (WithProtocolTemperature pt) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

traverseApplicative f ⇒ (a → f b) → WithProtocolTemperature pt a → f (WithProtocolTemperature pt b) #

sequenceAApplicative f ⇒ WithProtocolTemperature pt (f a) → f (WithProtocolTemperature pt a) #

mapMMonad m ⇒ (a → m b) → WithProtocolTemperature pt a → m (WithProtocolTemperature pt b) #

sequenceMonad m ⇒ WithProtocolTemperature pt (m a) → m (WithProtocolTemperature pt a) #

Applicative (WithProtocolTemperature 'Established) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Applicative (WithProtocolTemperature 'Hot) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Applicative (WithProtocolTemperature 'Warm) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Functor (WithProtocolTemperature pt) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

fmap ∷ (a → b) → WithProtocolTemperature pt a → WithProtocolTemperature pt b #

(<$) ∷ a → WithProtocolTemperature pt b → WithProtocolTemperature pt a #

Monoid a ⇒ Monoid (WithProtocolTemperature 'Established a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Monoid a ⇒ Monoid (WithProtocolTemperature 'Hot a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Monoid a ⇒ Monoid (WithProtocolTemperature 'Warm a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Semigroup a ⇒ Semigroup (WithProtocolTemperature 'Established a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Semigroup a ⇒ Semigroup (WithProtocolTemperature 'Hot a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Semigroup a ⇒ Semigroup (WithProtocolTemperature 'Warm a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Show a ⇒ Show (WithProtocolTemperature pt a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Eq a ⇒ Eq (WithProtocolTemperature pt a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

data TemperatureBundle a Source #

A bundle of HotApp, WarmApp and EstablishedApp.

Constructors

TemperatureBundle 

Fields

Instances

Instances details
Foldable TemperatureBundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

foldMonoid m ⇒ TemperatureBundle m → m #

foldMapMonoid m ⇒ (a → m) → TemperatureBundle a → m #

foldMap'Monoid m ⇒ (a → m) → TemperatureBundle a → m #

foldr ∷ (a → b → b) → b → TemperatureBundle a → b #

foldr' ∷ (a → b → b) → b → TemperatureBundle a → b #

foldl ∷ (b → a → b) → b → TemperatureBundle a → b #

foldl' ∷ (b → a → b) → b → TemperatureBundle a → b #

foldr1 ∷ (a → a → a) → TemperatureBundle a → a #

foldl1 ∷ (a → a → a) → TemperatureBundle a → a #

toListTemperatureBundle a → [a] #

nullTemperatureBundle a → Bool #

lengthTemperatureBundle a → Int #

elemEq a ⇒ a → TemperatureBundle a → Bool #

maximumOrd a ⇒ TemperatureBundle a → a #

minimumOrd a ⇒ TemperatureBundle a → a #

sumNum a ⇒ TemperatureBundle a → a #

productNum a ⇒ TemperatureBundle a → a #

Traversable TemperatureBundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

traverseApplicative f ⇒ (a → f b) → TemperatureBundle a → f (TemperatureBundle b) #

sequenceAApplicative f ⇒ TemperatureBundle (f a) → f (TemperatureBundle a) #

mapMMonad m ⇒ (a → m b) → TemperatureBundle a → m (TemperatureBundle b) #

sequenceMonad m ⇒ TemperatureBundle (m a) → m (TemperatureBundle a) #

Applicative TemperatureBundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Functor TemperatureBundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

fmap ∷ (a → b) → TemperatureBundle a → TemperatureBundle b #

(<$) ∷ a → TemperatureBundle b → TemperatureBundle a #

Monoid a ⇒ Monoid (TemperatureBundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Semigroup a ⇒ Semigroup (TemperatureBundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Show a ⇒ Show (TemperatureBundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Eq a ⇒ Eq (TemperatureBundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Mux mini-protocol callback

data MiniProtocolCb ctx bytes m a where Source #

A callback executed by each muxed mini-protocol.

Constructors

MiniProtocolCb ∷ (ctx → Channel m bytes → m (a, Maybe bytes)) → MiniProtocolCb ctx bytes m a 
MuxPeer ∷ ∀ (pr ∷ PeerRole) ps (st ∷ ps) failure ctx bytes m a. (Show failure, ∀ (st' ∷ ps). Show (ClientHasAgency st'), ∀ (st' ∷ ps). Show (ServerHasAgency st'), ShowProxy ps) ⇒ (ctx → (Tracer m (TraceSendRecv ps), Codec ps failure m bytes, Peer ps pr st m a)) → MiniProtocolCb ctx bytes m a

Deprecated: Use either MiniProtocolCb type instead of MiniProtocolCb type, ormkMiniProtocolCbFromPeer instead the MiniProtocolCb constructor.

MuxPeerPipelined ∷ ∀ (pr ∷ PeerRole) ps (st ∷ ps) failure ctx bytes m a. (Show failure, ∀ (st' ∷ ps). Show (ClientHasAgency st'), ∀ (st' ∷ ps). Show (ServerHasAgency st'), ShowProxy ps) ⇒ (ctx → (Tracer m (TraceSendRecv ps), Codec ps failure m bytes, PeerPipelined ps pr st m a)) → MiniProtocolCb ctx bytes m a

Deprecated: Use mkMiniProtocolCbFromPeer instead

Bundled Patterns

pattern MuxPeerRaw ∷ ∀ ctx bytes m a. (ctx → Channel m bytes → m (a, Maybe bytes)) → MiniProtocolCb ctx bytes m a

Deprecated: Use MiniProtocolCb instead

runMiniProtocolCb ∷ (MonadAsync m, MonadThrow m) ⇒ MiniProtocolCb ctx ByteString m a → ctx → Channel m → m (a, Maybe ByteString) Source #

Run a MiniProtocolCb using supplied ctx and Channel

mkMiniProtocolCbFromPeer ∷ ∀ (pr ∷ PeerRole) ps (st ∷ ps) failure bytes ctx m a. (MonadThrow m, Show failure, ∀ (st' ∷ ps). Show (ClientHasAgency st'), ∀ (st' ∷ ps). Show (ServerHasAgency st'), ShowProxy ps) ⇒ (ctx → (Tracer m (TraceSendRecv ps), Codec ps failure m bytes, Peer ps pr st m a)) → MiniProtocolCb ctx bytes m a Source #

Create a MiniProtocolCb from a tracer, codec and Peer.

mkMiniProtocolCbFromPeerPipelined ∷ ∀ (pr ∷ PeerRole) ps (st ∷ ps) failure ctx bytes m a. (MonadAsync m, MonadThrow m, Show failure, ∀ (st' ∷ ps). Show (ClientHasAgency st'), ∀ (st' ∷ ps). Show (ServerHasAgency st'), ShowProxy ps) ⇒ (ctx → (Tracer m (TraceSendRecv ps), Codec ps failure m bytes, PeerPipelined ps pr st m a)) → MiniProtocolCb ctx bytes m a Source #

Create a MiniProtocolCb from a tracer, codec and PeerPipelined.

Mux mini-protocol callback in MuxMode

data RunMiniProtocol (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b where Source #

RunMiniProtocol. It also capture context (the IsBigLedgerPeer) which is passed to the mini-protocol when a mini-protocol is started.

Constructors

InitiatorProtocolOnlyMiniProtocolCb initiatorCtx bytes m a → RunMiniProtocol InitiatorMode initiatorCtx responderCtx bytes m a Void 
ResponderProtocolOnlyMiniProtocolCb responderCtx bytes m b → RunMiniProtocol ResponderMode initiatorCtx responderCtx bytes m Void b 
InitiatorAndResponderProtocolMiniProtocolCb initiatorCtx bytes m a → MiniProtocolCb responderCtx bytes m b → RunMiniProtocol InitiatorResponderMode initiatorCtx responderCtx bytes m a b 

type RunMiniProtocolWithExpandedCtx mode peerAddr bytes m a b = RunMiniProtocol mode (ExpandedInitiatorContext peerAddr m) (ResponderContext peerAddr) bytes m a b Source #

RunMiniProtocol with ExpandedInitiatorContext and ResponderContext.

Used to run P2P node-to-node applications.

type RunMiniProtocolWithMinimalCtx mode peerAddr bytes m a b = RunMiniProtocol mode (MinimalInitiatorContext peerAddr) (ResponderContext peerAddr) bytes m a b Source #

RunMiniProtocol with MinimalInitiatorContext and ResponderContext.

Use to run node-to-client application as well as in some non p2p contexts.

MiniProtocol description

data MiniProtocol (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b Source #

Each mini-protocol is represented by its

  • mini-protocol number,
  • ingress size limit, and
  • callbacks.

Constructors

MiniProtocol 

Fields

type MiniProtocolWithExpandedCtx mode peerAddr bytes m a b = MiniProtocol mode (ExpandedInitiatorContext peerAddr m) (ResponderContext peerAddr) bytes m a b Source #

MiniProtocol type used in P2P.

type MiniProtocolWithMinimalCtx mode peerAddr bytes m a b = MiniProtocol mode (MinimalInitiatorContext peerAddr) (ResponderContext peerAddr) bytes m a b Source #

MiniProtocol type used in non-P2P.

newtype MiniProtocolNum Source #

The wire format includes the protocol numbers, and it's vital that these are stable. They are not necessarily dense however, as new ones are added and some old ones retired. So we use a dedicated class for this rather than reusing Enum. This also covers unrecognised protocol numbers on the decoding side.

Constructors

MiniProtocolNum Word16 

Instances

Instances details
Enum MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Ix MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Show MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Eq MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Ord MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

newtype MiniProtocolLimits Source #

Per Miniprotocol limits

Constructors

MiniProtocolLimits 

Fields

  • maximumIngressQueueInt

    Limit on the maximum number of bytes that can be queued in the miniprotocol's ingress queue.

MiniProtocol bundle

type OuroborosBundle (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b = TemperatureBundle [MiniProtocol mode initiatorCtx responderCtx bytes m a b] Source #

type OuroborosBundleWithExpandedCtx (mode ∷ MuxMode) peerAddr bytes m a b = OuroborosBundle mode (ExpandedInitiatorContext peerAddr m) (ResponderContext peerAddr) bytes m a b Source #

OuroborosBundle used in P2P.

Non-P2P API

newtype OuroborosApplication (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b Source #

Like MuxApplication but using a MiniProtocolCb rather than a raw Channel -> m a action.

Note: Only used in some non-P2P contexts.

Constructors

OuroborosApplication [MiniProtocol mode initiatorCtx responderCtx bytes m a b] 

type OuroborosApplicationWithMinimalCtx mode peerAddr bytes m a b = OuroborosApplication mode (MinimalInitiatorContext peerAddr) (ResponderContext peerAddr) bytes m a b Source #

OuroborosApplication used in NonP2P mode.

toApplication ∷ ∀ mode initiatorCtx responderCtx m a b. (MonadAsync m, MonadThrow m) ⇒ initiatorCtx → responderCtx → OuroborosApplication mode initiatorCtx responderCtx ByteString m a b → MuxApplication mode m a b Source #

Create non p2p mux application.

Note that callbacks will always receive IsNotBigLedgerPeer.

mkMiniProtocolBundleOuroborosBundle mode initiatorCtx responderCtx bytes m a b → MiniProtocolBundle mode Source #

Make MiniProtocolBundle, which is used to create a mux interface with newMux.

fromOuroborosBundleOuroborosBundle mode initiatorCtx responderCtx bytes m a b → OuroborosApplication mode initiatorCtx responderCtx bytes m a b Source #

contramapInitiatorCtx ∷ (initiatorCtx' → initiatorCtx) → OuroborosApplication mode initiatorCtx responderCtx bytes m a b → OuroborosApplication mode initiatorCtx' responderCtx bytes m a b Source #

Re-exports

data MuxError Source #

Error type used in across the mux layer.

Constructors

MuxError 

Instances

Instances details
Exception MuxError 
Instance details

Defined in Network.Mux.Trace

Generic MuxError 
Instance details

Defined in Network.Mux.Trace

Associated Types

type Rep MuxErrorTypeType #

Methods

fromMuxErrorRep MuxError x #

toRep MuxError x → MuxError #

Show MuxError 
Instance details

Defined in Network.Mux.Trace

Methods

showsPrecIntMuxErrorShowS #

showMuxErrorString #

showList ∷ [MuxError] → ShowS #

type Rep MuxError 
Instance details

Defined in Network.Mux.Trace

type Rep MuxError = D1 ('MetaData "MuxError" "Network.Mux.Trace" "network-mux-0.4.5.1-inplace" 'False) (C1 ('MetaCons "MuxError" 'PrefixI 'True) (S1 ('MetaSel ('Just "errorType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MuxErrorType) :*: S1 ('MetaSel ('Just "errorMsg") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)))

data MuxErrorType Source #

Enumeration of error conditions.

Constructors

MuxUnknownMiniProtocol

returned by decodeMuxSDUHeader, thrown by MuxBearer.

MuxDecodeError

return by decodeMuxSDUHeader, thrown by MuxBearer.

MuxBearerClosed

thrown by MuxBearer when received a null byte.

MuxIngressQueueOverRun

thrown by demux when violating maximumIngressQueue byte limit.

MuxInitiatorOnly

thrown when data arrives on a responder channel when the mux was set up as an InitiatorApp.

MuxIOException IOException

IOException thrown by

MuxSDUReadTimeout

thrown when reading of a single SDU takes too long

MuxSDUWriteTimeout

thrown when writing a single SDU takes too long

MuxShutdown !(Maybe MuxErrorType)

Result of runMiniProtocol's completionAction in case of an error or mux being closed while a mini-protocol was still running, this is not a clean exit.

MuxCleanShutdown

Mux stopped by stopMux

Instances

Instances details
Show MuxErrorType 
Instance details

Defined in Network.Mux.Trace

Eq MuxErrorType 
Instance details

Defined in Network.Mux.Trace

Deprecated APIs

type MuxPeer = MiniProtocolCb Source #

Deprecated: Use either MiniProtocolCb type instead of MiniProtocolCb type, ormkMiniProtocolCbFromPeer instead the MiniProtocolCb constructor.

runMuxPeerMiniProtocolCb ctx bytes m a → ctx → Channel m bytes → m (a, Maybe bytes) Source #