Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ouroboros.Network.Mux
Synopsis
- data MuxMode where
- data ProtocolTemperature
- = Established
- | Warm
- | Hot
- data SingProtocolTemperature (pt ∷ ProtocolTemperature) where
- data SomeTokProtocolTemperature where
- data WithProtocolTemperature (pt ∷ ProtocolTemperature) a where
- WithHot ∷ !a → WithProtocolTemperature Hot a
- WithWarm ∷ !a → WithProtocolTemperature Warm a
- WithEstablished ∷ !a → WithProtocolTemperature Established a
- withoutProtocolTemperature ∷ WithProtocolTemperature pt a → a
- data WithSomeProtocolTemperature a where
- withoutSomeProtocolTemperature ∷ WithSomeProtocolTemperature a → a
- data TemperatureBundle a = TemperatureBundle {}
- projectBundle ∷ SingProtocolTemperature pt → TemperatureBundle a → a
- data MiniProtocolCb ctx bytes m a where
- 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
- 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
- pattern MuxPeerRaw ∷ ∀ ctx bytes m a. (ctx → Channel m bytes → m (a, Maybe bytes)) → MiniProtocolCb ctx bytes m a
- runMiniProtocolCb ∷ (MonadAsync m, MonadThrow m) ⇒ MiniProtocolCb ctx ByteString m a → ctx → Channel m → m (a, Maybe ByteString)
- 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
- 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
- data RunMiniProtocol (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b where
- InitiatorProtocolOnly ∷ MiniProtocolCb initiatorCtx bytes m a → RunMiniProtocol InitiatorMode initiatorCtx responderCtx bytes m a Void
- ResponderProtocolOnly ∷ MiniProtocolCb responderCtx bytes m b → RunMiniProtocol ResponderMode initiatorCtx responderCtx bytes m Void b
- InitiatorAndResponderProtocol ∷ MiniProtocolCb 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
- type RunMiniProtocolWithMinimalCtx mode peerAddr bytes m a b = RunMiniProtocol mode (MinimalInitiatorContext peerAddr) (ResponderContext peerAddr) bytes m a b
- data MiniProtocol (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b = MiniProtocol {
- miniProtocolNum ∷ !MiniProtocolNum
- miniProtocolLimits ∷ !MiniProtocolLimits
- miniProtocolRun ∷ !(RunMiniProtocol mode initiatorCtx responderCtx bytes m a b)
- type MiniProtocolWithExpandedCtx mode peerAddr bytes m a b = MiniProtocol mode (ExpandedInitiatorContext peerAddr m) (ResponderContext peerAddr) bytes m a b
- type MiniProtocolWithMinimalCtx mode peerAddr bytes m a b = MiniProtocol mode (MinimalInitiatorContext peerAddr) (ResponderContext peerAddr) bytes m a b
- newtype MiniProtocolNum = MiniProtocolNum Word16
- newtype MiniProtocolLimits = MiniProtocolLimits {}
- type OuroborosBundle (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b = TemperatureBundle [MiniProtocol mode initiatorCtx responderCtx bytes m a b]
- type OuroborosBundleWithExpandedCtx (mode ∷ MuxMode) peerAddr bytes m a b = OuroborosBundle mode (ExpandedInitiatorContext peerAddr m) (ResponderContext peerAddr) bytes m a b
- newtype OuroborosApplication (mode ∷ MuxMode) initiatorCtx responderCtx bytes m a b = 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
- 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
- mkMiniProtocolBundle ∷ OuroborosBundle mode initiatorCtx responderCtx bytes m a b → MiniProtocolBundle mode
- fromOuroborosBundle ∷ OuroborosBundle mode initiatorCtx responderCtx bytes m a b → OuroborosApplication mode initiatorCtx responderCtx bytes m a b
- contramapInitiatorCtx ∷ (initiatorCtx' → initiatorCtx) → OuroborosApplication mode initiatorCtx responderCtx bytes m a b → OuroborosApplication mode initiatorCtx' responderCtx bytes m a b
- data MuxError = MuxError {}
- data MuxErrorType
- type family HasInitiator (mode ∷ MuxMode) ∷ Bool where ...
- type family HasResponder (mode ∷ MuxMode) ∷ Bool where ...
- type MuxPeer = MiniProtocolCb
- runMuxPeer ∷ MiniProtocolCb ctx bytes m a → ctx → Channel m bytes → m (a, Maybe bytes)
Basic notions
Constructors
InitiatorMode ∷ MuxMode | |
ResponderMode ∷ MuxMode | |
InitiatorResponderMode ∷ MuxMode |
data ProtocolTemperature Source #
There are three kinds of applications: warm, hot and established (ones that run in both warm and hot states).
Constructors
Established | |
Warm | |
Hot |
Instances
data SingProtocolTemperature (pt ∷ ProtocolTemperature) where Source #
Singletons for ProtocolTemperature
.
data SomeTokProtocolTemperature where Source #
Constructors
SomeTokProtocolTemperature ∷ SingProtocolTemperature pt → SomeTokProtocolTemperature |
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.
Constructors
WithHot ∷ !a → WithProtocolTemperature Hot a | |
WithWarm ∷ !a → WithProtocolTemperature Warm a | |
WithEstablished ∷ !a → WithProtocolTemperature Established a |
Instances
withoutProtocolTemperature ∷ WithProtocolTemperature pt a → a Source #
data WithSomeProtocolTemperature a where Source #
Constructors
WithSomeProtocolTemperature ∷ WithProtocolTemperature pt a → WithSomeProtocolTemperature a |
Instances
Functor WithSomeProtocolTemperature Source # | |
Defined in Ouroboros.Network.Mux Methods fmap ∷ (a → b) → WithSomeProtocolTemperature a → WithSomeProtocolTemperature b Source # (<$) ∷ a → WithSomeProtocolTemperature b → WithSomeProtocolTemperature a Source # | |
Show a ⇒ Show (WithSomeProtocolTemperature a) Source # | |
Defined in Ouroboros.Network.Mux |
data TemperatureBundle a Source #
A bundle of HotApp
, WarmApp
and EstablishedApp
.
Constructors
TemperatureBundle | |
Fields
|
Instances
projectBundle ∷ SingProtocolTemperature pt → TemperatureBundle a → a Source #
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 |
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
InitiatorProtocolOnly ∷ MiniProtocolCb initiatorCtx bytes m a → RunMiniProtocol InitiatorMode initiatorCtx responderCtx bytes m a Void | |
ResponderProtocolOnly ∷ MiniProtocolCb responderCtx bytes m b → RunMiniProtocol ResponderMode initiatorCtx responderCtx bytes m Void b | |
InitiatorAndResponderProtocol ∷ MiniProtocolCb 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
newtype MiniProtocolLimits Source #
Per Miniprotocol limits
Constructors
MiniProtocolLimits | |
Fields
|
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
.
mkMiniProtocolBundle ∷ OuroborosBundle mode initiatorCtx responderCtx bytes m a b → MiniProtocolBundle mode Source #
Make MiniProtocolBundle
, which is used to create a mux interface with
newMux
.
fromOuroborosBundle ∷ OuroborosBundle 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
from Network.Mux
Error type used in across the mux layer.
Constructors
MuxError | |
Fields
|
Instances
Exception MuxError | |
Defined in Network.Mux.Trace Methods toException ∷ MuxError → SomeException Source # | |
Generic MuxError | |
Show MuxError | |
type Rep MuxError | |
Defined in Network.Mux.Trace type Rep MuxError = D1 ('MetaData "MuxError" "Network.Mux.Trace" "network-mux-0.4.0.0-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 |
MuxDecodeError | return by |
MuxBearerClosed | thrown by |
MuxIngressQueueOverRun | thrown by |
MuxInitiatorOnly | thrown when data arrives on a responder channel when the
mux was set up as an |
MuxIOException IOException |
|
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 |
Instances
Show MuxErrorType | |
Defined in Network.Mux.Trace | |
Eq MuxErrorType | |
Defined in Network.Mux.Trace Methods (==) ∷ MuxErrorType → MuxErrorType → Bool Source # (/=) ∷ MuxErrorType → MuxErrorType → Bool Source # |
type family HasInitiator (mode ∷ MuxMode) ∷ Bool where ... Source #
Equations
HasInitiator 'InitiatorMode = 'True | |
HasInitiator 'ResponderMode = 'False | |
HasInitiator 'InitiatorResponderMode = 'True |
type family HasResponder (mode ∷ MuxMode) ∷ Bool where ... Source #
Equations
HasResponder 'InitiatorMode = 'False | |
HasResponder 'ResponderMode = 'True | |
HasResponder 'InitiatorResponderMode = 'True |
Deprecated APIs
type MuxPeer = MiniProtocolCb Source #
Deprecated: Use either MiniProtocolCb
type instead of MiniProtocolCb
type, ormkMiniProtocolCbFromPeer
instead the MiniProtocolCb
constructor.
runMuxPeer ∷ MiniProtocolCb ctx bytes m a → ctx → Channel m bytes → m (a, Maybe bytes) Source #