ouroboros-network-framework
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Protocol.Handshake

Description

API for running Handshake protocol.

Synopsis

Documentation

runHandshakeClient :: (MonadAsync m, MonadFork m, MonadTimer m, MonadMask m, MonadThrow (STM m), Ord vNumber) => Bearer m -> connectionId -> HandshakeArguments connectionId vNumber vData m -> Versions vNumber vData application -> m (Either (HandshakeException vNumber) (HandshakeResult application vNumber vData)) Source #

Run client side of the Handshake protocol

runHandshakeServer :: (MonadAsync m, MonadFork m, MonadTimer m, MonadMask m, MonadThrow (STM m), Ord vNumber) => Bearer m -> connectionId -> HandshakeArguments connectionId vNumber vData m -> Versions vNumber vData application -> m (Either (HandshakeException vNumber) (HandshakeResult application vNumber vData)) Source #

Run server side of the Handshake protocol.

data HandshakeArguments connectionId vNumber vData (m :: Type -> Type) Source #

Common arguments for both Handshake client & server.

Constructors

HandshakeArguments 

Fields

newtype Versions vNum vData r Source #

The version map supported by the local agent keyed on the version identifier.

Each Version contains a function which takes negotiated version data and returns negotiated application (the r type variable).

If one needs to combine multiple versions the simplest way is to use one of the combinators: foldMapVersions, combineVersions or the Semigroup instance directly:

fold $ (simpleSingletonVersions ...)
      :| [ (simpleSingletonVersions ...)
         , (simpleSingletonVersions ...)
         , ...
         ]

Constructors

Versions 

Fields

Instances

Instances details
Functor (Versions vNum extra) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Version

Methods

fmap :: (a -> b) -> Versions vNum extra a -> Versions vNum extra b #

(<$) :: a -> Versions vNum extra b -> Versions vNum extra a #

Ord vNum => Semigroup (Versions vNum vData r) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Version

Methods

(<>) :: Versions vNum vData r -> Versions vNum vData r -> Versions vNum vData r #

sconcat :: NonEmpty (Versions vNum vData r) -> Versions vNum vData r #

stimes :: Integral b => b -> Versions vNum vData r -> Versions vNum vData r #

data HandshakeException vNumber Source #

Wrapper around initiator and responder errors experienced by tryHandshake.

Instances

Instances details
Show vNumber => Show (HandshakeException vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake

data HandshakeProtocolError vNumber Source #

Extends handshake error RefuseReason type, by client specific errors.

data HandshakeResult r vNumber vData Source #

The result of a handshake.

Constructors

HandshakeNegotiationResult r vNumber vData 
HandshakeQueryResult (Map vNumber (Either Text vData)) 

data RefuseReason vNumber Source #

Reasons by which a server can refuse proposed version.

Constructors

VersionMismatch [vNumber] [Int]

All of the prosed versions where not known to the server. Since the server sends all versions that it can knows about, some of them we might not be able to decode, so we include raw tags [Int].

HandshakeDecodeError vNumber Text

The server failed to decode version parameters.

Refused vNumber Text

The server refused to run the proposed version parameters

Instances

Instances details
NFData vNumber => NFData (RefuseReason vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

rnf :: RefuseReason vNumber -> () #

(Typeable vNumber, Show vNumber) => Exception (RefuseReason vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Generic (RefuseReason vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Associated Types

type Rep (RefuseReason vNumber) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

from :: RefuseReason vNumber -> Rep (RefuseReason vNumber) x #

to :: Rep (RefuseReason vNumber) x -> RefuseReason vNumber #

Show vNumber => Show (RefuseReason vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showsPrec :: Int -> RefuseReason vNumber -> ShowS #

show :: RefuseReason vNumber -> String #

showList :: [RefuseReason vNumber] -> ShowS #

Eq vNumber => Eq (RefuseReason vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

(==) :: RefuseReason vNumber -> RefuseReason vNumber -> Bool #

(/=) :: RefuseReason vNumber -> RefuseReason vNumber -> Bool #

type Rep (RefuseReason vNumber) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data Accept vData #

A Maybe like type which better explains its purpose.

Constructors

Accept vData 
Refuse !Text 

Instances

Instances details
Show vData => Show (Accept vData) 
Instance details

Defined in Ouroboros.Network.Handshake.Acceptable

Methods

showsPrec :: Int -> Accept vData -> ShowS #

show :: Accept vData -> String #

showList :: [Accept vData] -> ShowS #

Eq vData => Eq (Accept vData) 
Instance details

Defined in Ouroboros.Network.Handshake.Acceptable

Methods

(==) :: Accept vData -> Accept vData -> Bool #

(/=) :: Accept vData -> Accept vData -> Bool #

handshake_QUERY_SHUTDOWN_DELAY :: DiffTime Source #

A 20s delay after query result was send back, before we close the connection. After that delay we close the connection.