ouroboros-network-framework
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.InboundGovernor.State

Contents

Description

Inbound protocol governor state.

The module should be imported qualified.

Synopsis

Documentation

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.

Internals

mkPublicState :: forall (muxMode :: Mode) initatorCtx versionData peerAddr (m :: Type -> Type) a b. State muxMode initatorCtx peerAddr versionData m a b -> PublicState peerAddr versionData Source #

Smart constructor for PublicState.

NOTE: we assume that all inbound connections share the same address. This is true in P2P mode since all outbound connections (which also can end up in the State) bind the server address. This allows us to use mapKeysMonotonic.

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

State, which consist of pure part, and a mutable part. The mutable part can be observable from outside. Future version could contain additional statistics on the peers.

Constructors

State 

Fields

  • connections :: !(Map (ConnectionId peerAddr) (ConnectionState muxMode initiatorCtx peerAddr versionData m a b))

    Map of connections state. Modifying igsConnections outside of inboundGovernorLoop is not safe.

  • matureDuplexPeers :: !(Map peerAddr versionData)

    Map of mature duplex peers.

    We don't add new duplex connections immediately, but only after a 15mins delay (defined in inboundMaturePeerDelay.

  • freshDuplexPeers :: !(OrdPSQ peerAddr Time versionData)

    Queue of fresh duplex connections ordered by time of arrival. Only connections younger than than 15mins are kept in this data structure.

  • countersCache :: !(Cache Counters)

    Counters counters cache. Allows to only trace values when necessary.

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

Per connection state tracked by inbound protocol governor.

Constructors

ConnectionState 

Fields

data Counters Source #

Counters for tracing and analysis purposes

Constructors

Counters 

Fields

counters :: forall (muxMode :: Mode) initiatorCtx peerAddr versionData (m :: Type -> Type) a b. State muxMode initiatorCtx peerAddr versionData m a b -> Counters Source #

unregisterConnection :: forall peerAddr (muxMode :: Mode) initiatorCtx versionData (m :: Type -> Type) a b. Ord peerAddr => ConnectionId peerAddr -> State muxMode initiatorCtx peerAddr versionData m a b -> State muxMode initiatorCtx peerAddr versionData m a b Source #

Remove connection from State.

updateMiniProtocol :: forall peerAddr (m :: Type -> Type) b (muxMode :: Mode) initiatorCtx versionData a. Ord peerAddr => ConnectionId peerAddr -> MiniProtocolNum -> STM m (Either SomeException b) -> State muxMode initiatorCtx peerAddr versionData m a b -> State muxMode initiatorCtx peerAddr versionData m a b Source #

Update a mini-protocol in ConnectionState. Once a mini-protocol was restarted we put the new completion action into csCompletionMap.

data RemoteState (m :: Type -> Type) Source #

Each inbound connection is either in RemoteIdle, RemoteCold or RemoteEstablished state. We only need to support PromotedToWarm^{Duplex}_{Remote}, DemotedToCold^{Duplex}_{Remote} and DemotedToCold^{Unidirectional}_{Remote} transitions.

Constructors

RemoteWarm

After PromotedToWarm^{dataFlow}_{Remote} a connection is in RemoteWarm state.

RemoteHot

In this state all established and hot mini-protocols are running and none of the warm mini-protocols is running.

RemoteIdle !(STM m ())

After DemotedToCold^{dataFlow}_{Remote} is detected. This state corresponds to InboundIdleState. In this state we are checking if the responder protocols are idle during protocol idle timeout (represented by an STM action)

RemoteIdle is the initial state of an accepted a connection.

RemoteCold

The RemoteCold state for Duplex connections allows us to have responders started using the on-demand strategy. This assures that once the remote peer start using the connection the local side will be ready to serve it.

For a Duplex connection: a RemoteIdle connection transitions to RemoteCold state after all responders being idle for protocolIdleTimeout. This triggers unregisterInboundConnection.

For a Unidreictional connection: after all responders terminated.

Bundled Patterns

pattern RemoteEstablished :: RemoteState m 

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

mkRemoteSt :: forall (m :: Type -> Type). RemoteState m -> RemoteSt Source #

updateRemoteState :: forall peerAddr (m :: Type -> Type) (muxMode :: Mode) initiatorCtx versionData a b. Ord peerAddr => ConnectionId peerAddr -> RemoteState m -> State muxMode initiatorCtx peerAddr versionData m a b -> State muxMode initiatorCtx peerAddr versionData m a b Source #

Set csRemoteState for a given connection.

mapRemoteState :: forall peerAddr (m :: Type -> Type) (muxMode :: Mode) initiatorCtx versionData a b. Ord peerAddr => ConnectionId peerAddr -> (RemoteState m -> RemoteState m) -> State muxMode initiatorCtx peerAddr versionData m a b -> State muxMode initiatorCtx peerAddr versionData m a b Source #

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

Constructors

MiniProtocolData 

Fields