ouroboros-network-0.1.0.0: A networking layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.NodeToClient

Description

This is the starting point for a module that will bring together the overall node to client protocol, as a collection of mini-protocols.

Synopsis

Documentation

nodeToClientProtocols ∷ (ConnectionId addr → STM m ControlMessageNodeToClientProtocols appType bytes m a b) → NodeToClientVersionOuroborosApplication appType addr bytes m a b Source #

Make an OuroborosApplication for the bundle of mini-protocols that make up the overall node-to-client protocol.

This function specifies the wire format protocol numbers as well as the protocols that run for each NodeToClientVersion.

They are chosen to not overlap with the node to node protocol numbers. This is not essential for correctness, but is helpful to allow a single shared implementation of tools that can analyse both protocols, e.g. wireshark plugins.

data NodeToClientProtocols appType bytes m a b Source #

Recorod of node-to-client mini protocols.

Constructors

NodeToClientProtocols 

Fields

data NodeToClientVersion Source #

Enumeration of node to client protocol versions.

Constructors

NodeToClientV_9

enabled CardanoNodeToClientVersion7, i.e., Alonzo

NodeToClientV_10

added GetChainBlockNo and GetChainPoint queries

NodeToClientV_11

added GetRewardInfoPools Block query

NodeToClientV_12

added LocalTxMonitor mini-protocol

NodeToClientV_13

enabled CardanoNodeToClientVersion9, i.e., Babbage

Instances

Instances details
Bounded NodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Network.NodeToClient.Version

Enum NodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Network.NodeToClient.Version

Eq NodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Network.NodeToClient.Version

Ord NodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Network.NodeToClient.Version

Show NodeToClientVersion Source # 
Instance details

Defined in Ouroboros.Network.NodeToClient.Version

data NetworkConnectTracers addr vNumber Source #

Tracer used by connectToNode (and derivatives, like connectTo or 'Ouroboros.Network.NodeToClient.connectTo).

Constructors

NetworkConnectTracers 

Fields

connectTo Source #

Arguments

LocalSnocket

callback constructed by withIOManager

NetworkConnectTracers LocalAddress NodeToClientVersion 
Versions NodeToClientVersion NodeToClientVersionData (OuroborosApplication InitiatorMode LocalAddress ByteString IO a b)

A dictionary of protocol versions & applications to run on an established connection. The application to run will be chosen by initial handshake protocol (the highest shared version will be chosen).

FilePath

path of the unix socket or named pipe

IO () 

A specialised version of connectToNode. It is a general purpose function which can connect using any version of the protocol. This is mostly useful for future enhancements.

data NetworkServerTracers addr vNumber Source #

Tracers required by a server which handles inbound connections.

Constructors

NetworkServerTracers 

Fields

data NetworkMutableState addr Source #

Mutable state maintained by the network component.

Constructors

NetworkMutableState 

Fields

data NetworkSubscriptionTracers withIPList addr vNumber Source #

IP subscription tracers.

Constructors

NetworkSubscriptionTracers 

Fields

data ClientSubscriptionParams a Source #

Constructors

ClientSubscriptionParams 

Fields

Null Protocol Peers

chainSyncPeerNull ∷ ∀ (header ∷ Type) (point ∷ Type) (tip ∷ Type) m a. MonadTimer m ⇒ Peer (ChainSync header point tip) AsClient StIdle m a Source #

localStateQueryPeerNull ∷ ∀ (block ∷ Type) (point ∷ Type) (query ∷ TypeType) m a. MonadTimer m ⇒ Peer (LocalStateQuery block point query) AsClient StIdle m a Source #

localTxSubmissionPeerNull ∷ ∀ (tx ∷ Type) (reject ∷ Type) m a. MonadTimer m ⇒ Peer (LocalTxSubmission tx reject) AsClient StIdle m a Source #

localTxMonitorPeerNull ∷ ∀ (txid ∷ Type) (tx ∷ Type) (slot ∷ Type) m a. MonadTimer m ⇒ Peer (LocalTxMonitor txid tx slot) AsClient StIdle m a Source #

Re-exported network interface

newtype IOManager #

Constructors

IOManager 

Fields

withIOManager ∷ WithIOManager #

type LocalSnocket = Snocket IO LocalSocket LocalAddress Source #

System dependent LocalSnocket

localSnocketIOManagerLocalSnocket Source #

Create a LocalSnocket.

On Windows, there is no way to get path associated to a named pipe. To go around this, the address passed to open via LocalFamily will be referenced by LocalSocket.

newtype LocalSocket Source #

System dependent LocalSnocket type

Constructors

LocalSocket 

Fields

Instances

Instances details
Eq LocalSocket 
Instance details

Defined in Ouroboros.Network.Snocket

Show LocalSocket 
Instance details

Defined in Ouroboros.Network.Snocket

Generic LocalSocket 
Instance details

Defined in Ouroboros.Network.Snocket

Associated Types

type Rep LocalSocketTypeType Source #

type Rep LocalSocket 
Instance details

Defined in Ouroboros.Network.Snocket

type Rep LocalSocket = D1 ('MetaData "LocalSocket" "Ouroboros.Network.Snocket" "ouroboros-network-framework-0.1.0.0-inplace" 'True) (C1 ('MetaCons "LocalSocket" 'PrefixI 'True) (S1 ('MetaSel ('Just "getLocalHandle") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocalHandle)))

newtype LocalAddress Source #

Local address, on Unix is associated with AF_UNIX family, on

Windows with `named-pipes`.

Constructors

LocalAddress 

Fields

Instances

Instances details
Eq LocalAddress 
Instance details

Defined in Ouroboros.Network.Snocket

Ord LocalAddress 
Instance details

Defined in Ouroboros.Network.Snocket

Show LocalAddress 
Instance details

Defined in Ouroboros.Network.Snocket

Generic LocalAddress 
Instance details

Defined in Ouroboros.Network.Snocket

Associated Types

type Rep LocalAddressTypeType Source #

Hashable LocalAddress 
Instance details

Defined in Ouroboros.Network.Snocket

type Rep LocalAddress 
Instance details

Defined in Ouroboros.Network.Snocket

type Rep LocalAddress = D1 ('MetaData "LocalAddress" "Ouroboros.Network.Snocket" "ouroboros-network-framework-0.1.0.0-inplace" 'True) (C1 ('MetaCons "LocalAddress" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFilePath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)))

Versions

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) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Version

Methods

fmap ∷ (a → b) → Versions vNum extra a → Versions vNum extra b Source #

(<$) ∷ a → Versions vNum extra b → Versions vNum extra a Source #

Ord vNum ⇒ Semigroup (Versions vNum vData r) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Version

Methods

(<>)Versions vNum vData r → Versions vNum vData r → Versions vNum vData r Source #

sconcatNonEmpty (Versions vNum vData r) → Versions vNum vData r Source #

stimesIntegral b ⇒ b → Versions vNum vData r → Versions vNum vData r Source #

simpleSingletonVersions ∷ vNum → vData → r → Versions vNum vData r Source #

Singleton smart constructor for Versions.

foldMapVersions ∷ (Ord vNum, Foldable f, HasCallStack) ⇒ (x → Versions vNum extra r) → f x → Versions vNum extra r Source #

Useful for folding multiple Versions.

A foldMap restricted to the Versions Semigroup.

PRECONDITION: f x is non-empty.

combineVersions ∷ (Ord vNum, Foldable f, HasCallStack) ⇒ f (Versions vNum extra r) → Versions vNum extra r Source #

Codecs

nodeToClientHandshakeCodec ∷ MonadST m ⇒ Codec (Handshake NodeToClientVersion Term) DeserialiseFailure m ByteString Source #

nodeToClientVersionCodecCodecCBORTerm (Text, Maybe Int) NodeToClientVersion Source #

We set 16ths bit to distinguish NodeToNodeVersion and NodeToClientVersion. This way connecting wrong protocol suite will fail during Handshake negotiation

This is done in backward compatible way, so NodeToClientV_1 encoding is not changed.

Re-exports

data ConnectionId addr Source #

Connection is identified by local and remote address.

TODO: the type variable which this data type fills in is called peerid. We should renamed to connectionId.

Constructors

ConnectionId 

Fields

Instances

Instances details
Eq addr ⇒ Eq (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

(==)ConnectionId addr → ConnectionId addr → Bool Source #

(/=)ConnectionId addr → ConnectionId addr → Bool Source #

Ord addr ⇒ Ord (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

compareConnectionId addr → ConnectionId addr → Ordering Source #

(<)ConnectionId addr → ConnectionId addr → Bool Source #

(<=)ConnectionId addr → ConnectionId addr → Bool Source #

(>)ConnectionId addr → ConnectionId addr → Bool Source #

(>=)ConnectionId addr → ConnectionId addr → Bool Source #

maxConnectionId addr → ConnectionId addr → ConnectionId addr Source #

minConnectionId addr → ConnectionId addr → ConnectionId addr Source #

Show addr ⇒ Show (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

showsPrecIntConnectionId addr → ShowS Source #

showConnectionId addr → String Source #

showList ∷ [ConnectionId addr] → ShowS Source #

Generic (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Associated Types

type Rep (ConnectionId addr) ∷ TypeType Source #

Methods

fromConnectionId addr → Rep (ConnectionId addr) x Source #

toRep (ConnectionId addr) x → ConnectionId addr Source #

Typeable addr ⇒ NoThunks (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

noThunks ∷ Context → ConnectionId addr → IO (Maybe ThunkInfo)

wNoThunks ∷ Context → ConnectionId addr → IO (Maybe ThunkInfo)

showTypeOfProxy (ConnectionId addr) → String

Hashable a ⇒ Hashable (ConnectionId a) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

hashWithSaltIntConnectionId a → Int

hashConnectionId a → Int

type Rep (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

type Rep (ConnectionId addr) = D1 ('MetaData "ConnectionId" "Ouroboros.Network.ConnectionId" "ouroboros-network-framework-0.1.0.0-inplace" 'False) (C1 ('MetaCons "ConnectionId" 'PrefixI 'True) (S1 ('MetaSel ('Just "localAddress") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 addr) :*: S1 ('MetaSel ('Just "remoteAddress") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 addr)))

data ErrorPolicies Source #

List of error policies for exception handling and a policy for handing application return values.

Constructors

ErrorPolicies 

Fields

networkErrorPoliciesErrorPolicies Source #

ErrorPolicies for client application. Additional rules can be added by means of a Semigroup instance of ErrorPolicies.

This error policies will try to preserve subscriptionWorker, e.g. if the connect function throws an IOException we will suspend it for a shortDelay, and try to re-connect.

This allows to recover from a situation where a node temporarily shutsdown, or running a client application which is subscribed two more than one node (possibly over network).

data ErrorPolicy where Source #

Constructors

ErrorPolicy 

Fields

Instances

Instances details
Show ErrorPolicy 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

data ErrorPolicyTrace Source #

Trace data for error policies

Constructors

ErrorPolicySuspendPeer (Maybe (ConnectionOrApplicationExceptionTrace SomeException)) DiffTime DiffTime

suspending peer with a given exception until

ErrorPolicySuspendConsumer (Maybe (ConnectionOrApplicationExceptionTrace SomeException)) DiffTime

suspending consumer until

ErrorPolicyLocalNodeError (ConnectionOrApplicationExceptionTrace SomeException)

caught a local exception

ErrorPolicyResumePeer

resume a peer (both consumer and producer)

ErrorPolicyKeepSuspended

consumer was suspended until producer will resume

ErrorPolicyResumeConsumer

resume consumer

ErrorPolicyResumeProducer

resume producer

ErrorPolicyUnhandledApplicationException SomeException

an application throwed an exception, which was not handled by any ErrorPolicy.

ErrorPolicyUnhandledConnectionException SomeException

connect throwed an exception, which was not handled by any ErrorPolicy.

ErrorPolicyAcceptException IOException

accept throwed an exception

Instances

Instances details
Show ErrorPolicyTrace 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

data WithAddr addr a Source #

Constructors

WithAddr 

Fields

Instances

Instances details
(Show addr, Show a) ⇒ Show (WithAddr addr a) 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

Methods

showsPrecIntWithAddr addr a → ShowS Source #

showWithAddr addr a → String Source #

showList ∷ [WithAddr addr a] → ShowS Source #

data SuspendDecision t Source #

Semigroup of commands which acts on PeerState. The t variable might be initiated to DiffTime or Time m.

This semigroup allows to either suspend both consumer and producer or just the consumer part.

Constructors

SuspendPeer !t !t

peer is suspend; The first t is the time until which a local producer is suspended, the second one is the time until which a local consumer is suspended.

SuspendConsumer !t

suspend local consumer / initiator side until t (this mean we are not allowing to communicate with the producer / responder of a remote peer).

Throw

throw an error from the main thread.

Instances

Instances details
Functor SuspendDecision 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Methods

fmap ∷ (a → b) → SuspendDecision a → SuspendDecision b Source #

(<$) ∷ a → SuspendDecision b → SuspendDecision a Source #

Eq t ⇒ Eq (SuspendDecision t) 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Ord t ⇒ Ord (SuspendDecision t) 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Show t ⇒ Show (SuspendDecision t) 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Ord t ⇒ Semigroup (SuspendDecision t)

The semigroup instance. Note that composing SuspendPeer with SuspendConsumer gives SuspendPeer. SuspendPeer and SuspendConsumer form a sub-semigroup.

Instance details

Defined in Ouroboros.Network.Subscription.PeerState

SAct (SuspendDecision Time) (Maybe (PeerState m))

Action of SuspendDecision on Maybe PeerState. We use this action together with alter function.

Note: SuspendDecision does not act on PeerState, only the sub-semigroup generated by SuspendConsumer and SuspendPeer does.

Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Methods

(<|)Maybe (PeerState m) → SuspendDecision Time → Maybe (PeerState m)

data TraceSendRecv ps where Source #

Structured Tracer output for runPeer and derivitives.

Constructors

TraceSendMsg ∷ ∀ ps. AnyMessageAndAgency ps → TraceSendRecv ps 
TraceRecvMsg ∷ ∀ ps. AnyMessageAndAgency ps → TraceSendRecv ps 

Instances

Instances details
Show (AnyMessageAndAgency ps) ⇒ Show (TraceSendRecv ps) 
Instance details

Defined in Ouroboros.Network.Driver.Simple

data Handshake (vNumber ∷ k) (vParams ∷ k1) Source #

The handshake mini-protocol is used initially to agree the version and associated parameters of the protocol to use for all subsequent communication.

Instances

Instances details
ShowProxy (Handshake vNumber vParams ∷ Type) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showProxyProxy (Handshake vNumber vParams) → String Source #

Show (ServerHasAgency st) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Show (ClientHasAgency st) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

(Show vNumber, Show vParams) ⇒ Show (Message (Handshake vNumber vParams) from to) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showsPrecIntMessage (Handshake vNumber vParams) from to → ShowS Source #

showMessage (Handshake vNumber vParams) from to → String Source #

showList ∷ [Message (Handshake vNumber vParams) from to] → ShowS Source #

Protocol (Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Associated Types

data Message (Handshake vNumber vParams) st st' #

data ClientHasAgency st #

data ServerHasAgency st #

data NobodyHasAgency st #

data ServerHasAgency (st ∷ Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data ServerHasAgency (st ∷ Handshake vNumber vParams) where
data NobodyHasAgency (st ∷ Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data NobodyHasAgency (st ∷ Handshake vNumber vParams) where
data Message (Handshake vNumber vParams) (from ∷ Handshake vNumber vParams) (to ∷ Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data Message (Handshake vNumber vParams) (from ∷ Handshake vNumber vParams) (to ∷ Handshake vNumber vParams) where
data ClientHasAgency (st ∷ Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data ClientHasAgency (st ∷ Handshake vNumber vParams) where

data LocalAddresses addr Source #

Constructors

LocalAddresses 

Fields

  • laIpv4Maybe addr

    Local IPv4 address to use, Nothing indicates don't use IPv4

  • laIpv6Maybe addr

    Local IPv6 address to use, Nothing indicates don't use IPv6

  • laUnixMaybe addr

    Local Unix address to use, Nothing indicates don't use Unix sockets

Instances

Instances details
Eq addr ⇒ Eq (LocalAddresses addr) 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Methods

(==)LocalAddresses addr → LocalAddresses addr → Bool Source #

(/=)LocalAddresses addr → LocalAddresses addr → Bool Source #

Show addr ⇒ Show (LocalAddresses addr) 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Semigroup (LocalAddresses addr) 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

type HandshakeTr ntcAddr ntcVersion = WithMuxBearer (ConnectionId ntcAddr) (TraceSendRecv (Handshake ntcVersion Term)) Source #