ouroboros-network-framework
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.InboundGovernor

Description

Server implementation based on ConnectionManager

This module should be imported qualified.

Synopsis

Run Inbound Protocol Governor

data PublicState peerAddr versionData Source #

Public inbound governor state.

Constructors

PublicState 

Fields

  • inboundDuplexPeers :: !(Map peerAddr versionData)

    A map of mature inbound duplex connections. These peers are used for light peer sharing (e.g. bootstrapping peer sharing).

  • remoteStateMap :: Map (ConnectionId peerAddr) RemoteSt

    Map of RemoteSt.

    It is lazy on purpose. It is created from igsConnections, so it should not point to any thunks that should be GC-ed leading to a memory leak.

data Arguments (muxMode :: Mode) handlerTrace socket peerAddr initiatorCtx responderCtx handle handleError versionNumber versionData bytes (m :: Type -> Type) a b x Source #

Constructors

Arguments 

Fields

with :: forall (muxMode :: Mode) socket peerAddr initiatorCtx responderCtx handle handlerTrace handleError versionData versionNumber bytes m a b x. (Alternative (STM m), MonadAsync m, MonadCatch m, MonadEvaluate m, MonadLabelledSTM m, MonadThrow m, MonadThrow (STM m), MonadTime m, MonadTimer m, MonadMask m, Ord peerAddr, HasResponder muxMode ~ 'True, MonadTraceSTM m, MonadFork m, MonadDelay m, Show peerAddr) => Arguments muxMode handlerTrace socket peerAddr initiatorCtx responderCtx handle handleError versionNumber versionData bytes m a b x -> (Async m Void -> m (PublicState peerAddr versionData) -> ConnectionManager muxMode socket peerAddr handle handleError m -> m x) -> m x Source #

Run the server, which consists of the following components:

  • inbound governor, it corresponds to p2p-governor on outbound side
  • accept loop(s), one per given ip address. We support up to one ipv4 address and up to one ipv6 address, i.e. an ipv6 enabled node will run two accept loops on listening on different addresses with shared inbound governor.

The server can be run in either of two Mode-es:

  • InitiatorResponderMode
  • ResponderMode

The first one is used in data diffusion for Node-To-Node protocol, while the other is useful for running a server for the Node-To-Client protocol.

Trace

data Trace peerAddr Source #

Instances

Instances details
Show peerAddr => Show (Trace peerAddr) Source # 
Instance details

Defined in Ouroboros.Network.InboundGovernor

Methods

showsPrec :: Int -> Trace peerAddr -> ShowS #

show :: Trace peerAddr -> String #

showList :: [Trace peerAddr] -> ShowS #

data Debug peerAddr versionData Source #

Constructors

Debug (State muxMode initiatorCtx peerAddr versionData m a b) 

data Event (muxMode :: Mode) handle initiatorCtx peerAddr versionData (m :: Type -> Type) a b Source #

Edge triggered events to which the inbound protocol governor reacts.

Constructors

NewConnection !(NewConnectionInfo peerAddr handle)

A request to start mini-protocol bundle, either from the server or from connection manager after a duplex connection was negotiated.

MuxFinished !(ConnectionId peerAddr) (STM m (Maybe SomeException))

A multiplexer exited.

MiniProtocolTerminated !(Terminated muxMode initiatorCtx peerAddr m a b)

A mini-protocol terminated either cleanly or abruptly.

WaitIdleRemote !(ConnectionId peerAddr)

Transition from RemoteEstablished to RemoteIdle.

RemotePromotedToHot !(ConnectionId peerAddr)

A remote warm → hot transition. It is scheduled as soon as all hot mini-protocols are running.

RemoteDemotedToWarm !(ConnectionId peerAddr)

A hot → warm transition. It is scheduled as soon as any hot mini-protocol terminates.

CommitRemote !(ConnectionId peerAddr)

Transition from RemoteIdle to RemoteCold.

AwakeRemote !(ConnectionId peerAddr)

Transition from RemoteIdle or RemoteCold to RemoteEstablished.

MaturedDuplexPeers

Update igsMatureDuplexPeers and igsFreshDuplexPeers.

Fields

  • !(Map peerAddr versionData)

    newly matured duplex peers

  • !(OrdPSQ peerAddr Time versionData)

    queue of fresh duplex peers

InactivityTimeout 

data NewConnectionInfo peerAddr handle Source #

Announcement message for a new connection.

Constructors

NewConnectionInfo !Provenance !(ConnectionId peerAddr) !DataFlow !handle

Announce a new connection. Inbound protocol governor will start responder protocols using StartOnDemand strategy and monitor remote transitions: PromotedToWarm^{Duplex}_{Remote} and DemotedToCold^{dataFlow}_{Remote}.

Instances

Instances details
Show peerAddr => Show (NewConnectionInfo peerAddr handle) Source # 
Instance details

Defined in Ouroboros.Network.InboundGovernor

Methods

showsPrec :: Int -> NewConnectionInfo peerAddr handle -> ShowS #

show :: NewConnectionInfo peerAddr handle -> String #

showList :: [NewConnectionInfo peerAddr handle] -> ShowS #

data RemoteSt Source #

Remote connection state tracked by inbound protocol governor.

This type is used for tracing.

Instances

Instances details
Show RemoteSt Source # 
Instance details

Defined in Ouroboros.Network.InboundGovernor.State

Eq RemoteSt Source # 
Instance details

Defined in Ouroboros.Network.InboundGovernor.State

type RemoteTransition = Transition' (Maybe RemoteSt) Source #

Nothing represents uninitialised state.

data AcceptConnectionsPolicyTrace Source #

Trace for the AcceptConnectionsLimit policy.

Re-exports

data Transition' state Source #

Constructors

Transition 

Fields

Instances

Instances details
Functor Transition' Source # 
Instance details

Defined in Ouroboros.Network.ConnectionManager.Types

Methods

fmap :: (a -> b) -> Transition' a -> Transition' b #

(<$) :: a -> Transition' b -> Transition' a #

Show state => Show (Transition' state) Source # 
Instance details

Defined in Ouroboros.Network.ConnectionManager.Types

Methods

showsPrec :: Int -> Transition' state -> ShowS #

show :: Transition' state -> String #

showList :: [Transition' state] -> ShowS #

Eq state => Eq (Transition' state) Source # 
Instance details

Defined in Ouroboros.Network.ConnectionManager.Types

Methods

(==) :: Transition' state -> Transition' state -> Bool #

(/=) :: Transition' state -> Transition' state -> Bool #

data TransitionTrace' id state Source #

Constructors

TransitionTrace 

Fields

Instances

Instances details
Functor (TransitionTrace' id) Source # 
Instance details

Defined in Ouroboros.Network.ConnectionManager.Types

Methods

fmap :: (a -> b) -> TransitionTrace' id a -> TransitionTrace' id b #

(<$) :: a -> TransitionTrace' id b -> TransitionTrace' id a #

(Show peerAddr, Show state) => Show (TransitionTrace' peerAddr state) Source # 
Instance details

Defined in Ouroboros.Network.ConnectionManager.Types

Methods

showsPrec :: Int -> TransitionTrace' peerAddr state -> ShowS #

show :: TransitionTrace' peerAddr state -> String #

showList :: [TransitionTrace' peerAddr state] -> ShowS #

data ResponderCounters Source #

The IG maintains a state of the number of hot and warm miniprotocol responders to track transitions and notify the connection manager for interesting events.

API's exported for testing purposes

maturedPeers :: Ord peerAddr => Time -> OrdPSQ peerAddr Time versionData -> (Map peerAddr versionData, OrdPSQ peerAddr Time versionData) Source #