ouroboros-network-0.10.1.0: A networking layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Network.NodeToNode

Description

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

Synopsis

Documentation

nodeToNodeProtocols Source #

Arguments

:: MiniProtocolParameters 
-> NodeToNodeProtocols muxMode initiatorCtx responderCtx bytes m a b 
-> NodeToNodeVersion 
-> PeerSharing

Node's own PeerSharing value

-> OuroborosBundle muxMode initiatorCtx responderCtx bytes m a b 

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

This function specifies the wire format protocol numbers.

The application specific protocol numbers start from 2. The MiniProtocolNum 0 is reserved for the Handshake protocol, while MiniProtocolNum 1 is reserved for DeltaQ messages. Handshake protocol is not included in NodeToNodeProtocols as it runs before mux is started but it reusing MuxBearer to send and receive messages. Only when the handshake protocol succeeds, we will know which protocols to run / multiplex.

These are chosen to not overlap with the node to client protocol numbers (and the handshake protocol number). 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 NodeToNodeProtocols appType initiatorCtx responderCtx bytes m a b Source #

Constructors

NodeToNodeProtocols 

Fields

  • chainSyncProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b

    chain-sync mini-protocol

  • blockFetchProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b

    block-fetch mini-protocol

  • txSubmissionProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b

    tx-submission mini-protocol

  • keepAliveProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b

    keep-alive mini-protocol

  • peerSharingProtocol :: RunMiniProtocol appType initiatorCtx responderCtx bytes m a b

    peer sharing mini-protocol

type NodeToNodeProtocolsWithExpandedCtx appType ntnAddr bytes m a b = NodeToNodeProtocols appType (ExpandedInitiatorContext ntnAddr m) (ResponderContext ntnAddr) bytes m a b Source #

type NodeToNodeProtocolsWithMinimalCtx appType ntnAddr bytes m a b = NodeToNodeProtocols appType (MinimalInitiatorContext ntnAddr) (ResponderContext ntnAddr) bytes m a b Source #

data MiniProtocolParameters Source #

Constructors

MiniProtocolParameters 

Fields

data NodeToNodeVersion #

Instances

Instances details
Bounded NodeToNodeVersion 
Instance details

Defined in Ouroboros.Network.NodeToNode.Version

Enum NodeToNodeVersion 
Instance details

Defined in Ouroboros.Network.NodeToNode.Version

Show NodeToNodeVersion 
Instance details

Defined in Ouroboros.Network.NodeToNode.Version

Eq NodeToNodeVersion 
Instance details

Defined in Ouroboros.Network.NodeToNode.Version

Ord NodeToNodeVersion 
Instance details

Defined in Ouroboros.Network.NodeToNode.Version

data NetworkConnectTracers addr vNumber #

Constructors

NetworkConnectTracers 

Fields

connectTo :: Snocket IO Socket SockAddr -> NetworkConnectTracers SockAddr NodeToNodeVersion -> Versions NodeToNodeVersion NodeToNodeVersionData (OuroborosApplicationWithMinimalCtx InitiatorMode SockAddr ByteString IO a b) -> Maybe SockAddr -> SockAddr -> IO () Source #

A specialised version of connectToNode.

data NetworkServerTracers addr vNumber #

Constructors

NetworkServerTracers 

Fields

data NetworkMutableState addr #

Constructors

NetworkMutableState 

Fields

withServer Source #

Arguments

:: SocketSnocket 
-> NetworkServerTracers SockAddr NodeToNodeVersion 
-> NetworkMutableState SockAddr 
-> AcceptedConnectionsLimit 
-> Socket

a configured socket to be used be the server. The server will call bind and listen methods but it will not set any socket or tcp options on it.

-> Versions NodeToNodeVersion NodeToNodeVersionData (OuroborosApplicationWithMinimalCtx ResponderMode SockAddr ByteString IO a b) 
-> ErrorPolicies 
-> IO Void 

A specialised version of withServerNode. It forks a thread which runs an accept loop (server thread):

  • when the server thread throws an exception the main thread rethrows it (by wait)
  • when an async exception is thrown to kill the main thread the server thread will be cancelled as well (by withAsync)

P2P Governor

data PeerAdvertise #

Instances

Instances details
FromJSON PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

Methods

parseJSON :: Value -> Parser PeerAdvertise

parseJSONList :: Value -> Parser [PeerAdvertise]

omittedField :: Maybe PeerAdvertise

ToJSON PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

Generic PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

Associated Types

type Rep PeerAdvertise :: Type -> Type Source #

Show PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

Eq PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

Ord PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

type Rep PeerAdvertise 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerAdvertise

type Rep PeerAdvertise = D1 ('MetaData "PeerAdvertise" "Ouroboros.Network.PeerSelection.PeerAdvertise" "ouroboros-network-api-0.6.1.0-5ZJryZo7Z8Q51J9KZLwxMb" 'False) (C1 ('MetaCons "DoNotAdvertisePeer" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DoAdvertisePeer" 'PrefixI 'False) (U1 :: Type -> Type))

data PeerSelectionTargets Source #

Adjustable targets for the peer selection mechanism.

These are used by the peer selection governor as targets. They are used by the peer churn governor loop as knobs to adjust, to influence the peer selection governor.

The known, established and active peer targets are targets both from below and from above: the governor will attempt to grow or shrink the sets to hit these targets.

Unlike the other targets, the root peer target is "one sided", it is only a target from below. The governor does not try to shrink the root set to hit it, it simply stops looking for more.

There is also an implicit target that enough local root peers are selected as active. This comes from the configuration for local roots, and is not an independently adjustable target.

Constructors

PeerSelectionTargets 

Fields

Subscription Workers

IP subscription worker

data NetworkSubscriptionTracers withIPList addr vNumber Source #

IP subscription tracers.

Constructors

NetworkSubscriptionTracers 

Fields

ipSubscriptionWorker :: forall mode x y. HasInitiator mode ~ True => SocketSnocket -> NetworkIPSubscriptionTracers SockAddr NodeToNodeVersion -> NetworkMutableState SockAddr -> IPSubscriptionParams () -> Versions NodeToNodeVersion NodeToNodeVersionData (OuroborosApplicationWithMinimalCtx mode SockAddr ByteString IO x y) -> IO Void Source #

ipSubscriptionWorker which starts given application versions on each established connection.

DNS subscription worker

data NetworkDNSSubscriptionTracers vNumber addr Source #

DNS subscription tracers.

Constructors

NetworkDNSSubscriptionTracers 

Fields

dnsSubscriptionWorker :: forall mode x y. HasInitiator mode ~ True => SocketSnocket -> NetworkDNSSubscriptionTracers NodeToNodeVersion SockAddr -> NetworkMutableState SockAddr -> DnsSubscriptionParams () -> Versions NodeToNodeVersion NodeToNodeVersionData (OuroborosApplicationWithMinimalCtx mode SockAddr ByteString IO x y) -> IO Void Source #

dnsSubscriptionWorker which starts given application versions on each established connection.

Versions

newtype Versions vNum vData r #

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 #

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

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

simpleSingletonVersions :: vNum -> vData -> r -> Versions vNum vData r #

foldMapVersions :: (Ord vNum, Foldable f, HasCallStack) => (x -> Versions vNum extra r) -> f x -> Versions vNum extra r #

combineVersions :: (Ord vNum, Foldable f, HasCallStack) => f (Versions vNum extra r) -> Versions vNum extra r #

Codecs

nodeToNodeHandshakeCodec :: forall (m :: Type -> Type). MonadST m => Codec (Handshake NodeToNodeVersion Term) DeserialiseFailure m ByteString #

Re-exports

newtype ResponderContext addr #

Constructors

ResponderContext 

Instances

Instances details
Functor ResponderContext 
Instance details

Defined in Ouroboros.Network.Context

data ConnectionId addr #

Constructors

ConnectionId 

Fields

Instances

Instances details
Functor ConnectionId 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

fmap :: (a -> b) -> ConnectionId a -> ConnectionId b Source #

(<$) :: a -> ConnectionId b -> ConnectionId a Source #

ShowProxy addr => ShowProxy (ConnectionId addr :: Type) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Methods

showProxy :: Proxy (ConnectionId addr) -> String

Generic (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

Associated Types

type Rep (ConnectionId addr) :: Type -> Type Source #

Methods

from :: ConnectionId addr -> Rep (ConnectionId addr) x Source #

to :: Rep (ConnectionId addr) x -> ConnectionId addr Source #

Show addr => Show (ConnectionId addr) 
Instance details

Defined in Ouroboros.Network.ConnectionId

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

Hashable a => Hashable (ConnectionId a) 
Instance details

Defined in Ouroboros.Network.ConnectionId

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)

showTypeOf :: Proxy (ConnectionId addr) -> String

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.10.1.0-6oc7eN9E7cu67rZ3WydsD2" 'False) (C1 ('MetaCons "ConnectionId" 'PrefixI 'True) (S1 ('MetaSel ('Just "localAddress") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 addr) :*: S1 ('MetaSel ('Just "remoteAddress") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 addr)))

type ControlMessageSTM (m :: Type -> Type) = STM m ControlMessage #

type RemoteAddress = SockAddr Source #

data Handshake (vNumber :: k) (vParams :: k1) #

Instances

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

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showProxy :: Proxy (Handshake vNumber vParams) -> String

Show (ClientHasAgency st) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showsPrec :: Int -> ClientHasAgency st -> ShowS Source #

show :: ClientHasAgency st -> String Source #

showList :: [ClientHasAgency st] -> ShowS Source #

Show (ServerHasAgency st) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showsPrec :: Int -> ServerHasAgency st -> ShowS Source #

show :: ServerHasAgency st -> String Source #

showList :: [ServerHasAgency st] -> ShowS Source #

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

Defined in Ouroboros.Network.Protocol.Handshake.Type

Methods

showsPrec :: Int -> Message (Handshake vNumber vParams) from to -> ShowS Source #

show :: Message (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

Methods

exclusionLemma_ClientAndServerHaveAgency :: forall (st :: Handshake vNumber vParams). ClientHasAgency st -> ServerHasAgency st -> Void

exclusionLemma_NobodyAndClientHaveAgency :: forall (st :: Handshake vNumber vParams). NobodyHasAgency st -> ClientHasAgency st -> Void

exclusionLemma_NobodyAndServerHaveAgency :: forall (st :: Handshake vNumber vParams). NobodyHasAgency st -> ServerHasAgency st -> Void

data ClientHasAgency (st :: Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data ClientHasAgency (st :: Handshake vNumber vParams) where
  • TokPropose :: forall {k} {k1} {vNumber :: k} {vParams :: k1}. ClientHasAgency ('StPropose :: Handshake vNumber vParams)
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 NobodyHasAgency (st :: Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data NobodyHasAgency (st :: Handshake vNumber vParams) where
  • TokDone :: forall {k} {k1} {vNumber :: k} {vParams :: k1}. NobodyHasAgency ('StDone :: Handshake vNumber vParams)
data ServerHasAgency (st :: Handshake vNumber vParams) 
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

data ServerHasAgency (st :: Handshake vNumber vParams) where
  • TokConfirm :: forall {k} {k1} {vNumber :: k} {vParams :: k1}. ServerHasAgency ('StConfirm :: Handshake vNumber vParams)

data LocalAddresses addr #

Constructors

LocalAddresses 

Fields

Instances

Instances details
Semigroup (LocalAddresses addr) 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Show addr => Show (LocalAddresses addr) 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Eq addr => Eq (LocalAddresses addr) 
Instance details

Defined in Ouroboros.Network.Subscription.Worker

data Socket #

Instances

Instances details
Show Socket 
Instance details

Defined in Network.Socket.Types

Eq Socket 
Instance details

Defined in Network.Socket.Types

Exceptions

Error Policies and Peer state

remoteNetworkErrorPolicy :: ErrorPolicies Source #

A minimal error policy for remote peers, which only handles exceptions raised by `ouroboros-network`.

localNetworkErrorPolicy :: ErrorPolicies Source #

Error policy for local clients. This is equivalent to nullErrorPolicies, but explicit in the errors which can be caught.

We are very permissive here, and very strict in the networkErrorPolicy. After any failure the client will be killed and not penalised by this policy. This allows to restart the local client without a delay.

data ErrorPolicy where #

Constructors

ErrorPolicy :: forall e. Exception e => (e -> Maybe (SuspendDecision DiffTime)) -> ErrorPolicy 

Instances

Instances details
Show ErrorPolicy 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

data SuspendDecision t #

Constructors

SuspendPeer !t !t 
SuspendConsumer !t 
Throw 

Instances

Instances details
Functor SuspendDecision 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Ord t => Semigroup (SuspendDecision t) 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

Show t => Show (SuspendDecision t) 
Instance details

Defined in Ouroboros.Network.Subscription.PeerState

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

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

Defined in Ouroboros.Network.Subscription.PeerState

Methods

(<|) :: Maybe (PeerState m) -> SuspendDecision Time -> Maybe (PeerState m)

Traces

data AcceptConnectionsPolicyTrace #

data TraceSendRecv ps where #

Constructors

TraceSendMsg :: forall ps. AnyMessageAndAgency ps -> TraceSendRecv ps 
TraceRecvMsg :: forall ps. AnyMessageAndAgency ps -> TraceSendRecv ps 

Instances

Instances details
Show (AnyMessageAndAgency ps) => Show (TraceSendRecv ps) 
Instance details

Defined in Ouroboros.Network.Driver.Simple

data WithIPList a #

Constructors

WithIPList 

Fields

Instances

Instances details
Show a => Show (WithIPList a) 
Instance details

Defined in Ouroboros.Network.Subscription.Ip

data WithDomainName a #

Constructors

WithDomainName 

Fields

Instances

Instances details
Show a => Show (WithDomainName a) 
Instance details

Defined in Ouroboros.Network.Subscription.Dns

data WithAddr addr a #

Constructors

WithAddr 

Fields

Instances

Instances details
(Show addr, Show a) => Show (WithAddr addr a) 
Instance details

Defined in Ouroboros.Network.ErrorPolicy

Methods

showsPrec :: Int -> WithAddr addr a -> ShowS Source #

show :: WithAddr addr a -> String Source #

showList :: [WithAddr addr a] -> ShowS Source #

type HandshakeTr ntnAddr ntnVersion = WithMuxBearer (ConnectionId ntnAddr) (TraceSendRecv (Handshake ntnVersion Term)) Source #

For Consensus ThreadNet Tests

chainSyncMiniProtocolNum :: MiniProtocolNum Source #

keepAliveMiniProtocolNum :: MiniProtocolNum Source #

Orphan instances

ShowProxy RemoteAddress Source # 
Instance details