ouroboros-network-framework-0.1.0.1
Safe Haskell None
Language Haskell2010

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 ) peerAddr bytes m a b Source #

States of the connection handler thread.

Constructors

Handle

data HandleError (muxMode :: MuxMode ) versionNumber where Source #

Constructors

HandleHandshakeClientError :: HasInitiator muxMode ~ True => !( HandshakeException versionNumber) -> HandleError muxMode versionNumber
HandleHandshakeServerError :: HasResponder muxMode ~ True => !( HandshakeException versionNumber) -> HandleError muxMode versionNumber
HandleError :: ! SomeException -> HandleError muxMode versionNumber

Instances

Instances details
Show versionNumber => Show ( HandleError muxMode versionNumber) Source #
Instance details

Defined in Ouroboros.Network.ConnectionHandler

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

Type of ConnectionHandler implemented in this module.

makeConnectionHandler Source #

Arguments

:: forall peerAddr muxMode socket versionNumber versionData m a b. ( MonadAsync m, MonadCatch m, MonadFork m, MonadLabelledSTM m, MonadThrow ( STM m), MonadTime 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 peerAddr 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 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 ConnectionManager s: 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 peerAddr versionNumber bytes m a b = ConnectionManager muxMode socket peerAddr ( Handle muxMode peerAddr bytes m a b) ( HandleError muxMode versionNumber) m Source #

Type alias for ConnectionManager using Handle .

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