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

Ouroboros.Network.ConnectionHandler

Contents

Description

Implementation of ConnectionHandler

While connection manager responsibility is to keep track of resources: sockets and threads running connection and their state changes (including changes imposed by ConnectionHandler, e.g. weather a uni- or duplex- data flow was negotiated), the responsibility of ConnectionHandler is to:

  • run handshake protocol on the underlying bearer
  • start mux

ConnectionHandler is run on each inbound or outbound connection and returns Handle. Upon successful handshake negotiation it returns all the necessary information to run mini-protocols. Note that it is not responsible for running them: that's what a server does or p2p-governor by means of PeerStateActions.

Synopsis

Documentation

data Handle (muxMode ∷ MuxMode) initiatorCtx responderCtx versionData bytes m a b Source #

States of the connection handler thread.

Constructors

Handle 

Fields

type HandleWithExpandedCtx muxMode peerAddr versionData bytes m a b = Handle muxMode (ExpandedInitiatorContext peerAddr m) (ResponderContext peerAddr) versionData bytes m a b Source #

Handle used by `node-to-node` P2P connections.

type HandleWithMinimalCtx muxMode peerAddr versionData bytes m a b = Handle muxMode (MinimalInitiatorContext peerAddr) (ResponderContext peerAddr) versionData bytes m a b Source #

Handle used by:

  • `node-to-node` non P2P mode;
  • `node-to-client` connections.

data HandleError (muxMode ∷ MuxMode) versionNumber where Source #

Constructors

HandleHandshakeClientErrorHasInitiator muxMode ~ True ⇒ !(HandshakeException versionNumber) → HandleError muxMode versionNumber 
HandleHandshakeServerErrorHasResponder muxMode ~ True ⇒ !(HandshakeException versionNumber) → HandleError muxMode versionNumber 
HandleError ∷ !SomeExceptionHandleError muxMode versionNumber 

Instances

Instances details
Show versionNumber ⇒ Show (HandleError muxMode versionNumber) Source # 
Instance details

Defined in Ouroboros.Network.ConnectionHandler

Methods

showsPrecIntHandleError muxMode versionNumber → ShowS #

showHandleError muxMode versionNumber → String #

showList ∷ [HandleError muxMode versionNumber] → ShowS #

type MuxConnectionHandler muxMode socket initiatorCtx responderCtx peerAddr versionNumber versionData bytes m a b = ConnectionHandler muxMode (ConnectionHandlerTrace versionNumber versionData) socket peerAddr (Handle muxMode initiatorCtx responderCtx versionData bytes m a b) (HandleError muxMode versionNumber) (versionNumber, versionData) m Source #

Type of ConnectionHandler implemented in this module.

makeConnectionHandler Source #

Arguments

∷ ∀ initiatorCtx responderCtx peerAddr muxMode socket versionNumber versionData m a b. (Alternative (STM m), MonadAsync m, MonadDelay m, MonadFork m, MonadLabelledSTM m, MonadThrow (STM m), MonadTimer m, MonadMask m, Ord versionNumber, Show peerAddr, Typeable peerAddr) 
Tracer m (WithMuxBearer (ConnectionId peerAddr) MuxTrace) 
SingMuxMode muxMode

describe whether this is outbound or inbound connection, and bring evidence that we can use mux with it.

HandshakeArguments (ConnectionId peerAddr) versionNumber versionData m 
Versions versionNumber versionData (OuroborosBundle muxMode initiatorCtx responderCtx ByteString m a b) 
→ (ThreadId m, RethrowPolicy)

ThreadId and rethrow policy. Rethrow policy might throw an async exception to that thread, when trying to terminate the process.

MuxConnectionHandler muxMode socket initiatorCtx responderCtx peerAddr versionNumber versionData ByteString m a b 

To be used as makeConnectionHandler field of ConnectionManagerArguments.

Note: We need to pass MiniProtocolBundle what forces us to have two different ConnectionManagers: one for `node-to-client` and another for `node-to-node` connections. But this is ok, as these resources are independent.

type MuxConnectionManager muxMode socket initiatorCtx responderCtx peerAddr versionData versionNumber bytes m a b = ConnectionManager muxMode socket peerAddr (Handle muxMode initiatorCtx responderCtx versionData bytes m a b) (HandleError muxMode versionNumber) m Source #

Type alias for ConnectionManager using Handle.

type ConnectionManagerWithExpandedCtx muxMode socket peerAddr versionData versionNumber bytes m a b = ConnectionManager muxMode socket peerAddr (HandleWithExpandedCtx muxMode peerAddr versionData bytes m a b) (HandleError muxMode versionNumber) m Source #

Type alias for ConnectionManager which is using expanded context.

tracing

data ConnectionHandlerTrace versionNumber versionData Source #

ConnectionHandlerTrace is embedded into ConnectionManagerTrace with ConnectionHandlerTrace constructor. It already includes ConnectionId so we don't need to take care of it here.

TODO: when Handshake will get its own tracer, independent of Mux, it should be embedded into ConnectionHandlerTrace.

Instances

Instances details
(Show versionNumber, Show versionData) ⇒ Show (ConnectionHandlerTrace versionNumber versionData) Source # 
Instance details

Defined in Ouroboros.Network.ConnectionHandler

Methods

showsPrecIntConnectionHandlerTrace versionNumber versionData → ShowS #

showConnectionHandlerTrace versionNumber versionData → String #

showList ∷ [ConnectionHandlerTrace versionNumber versionData] → ShowS #