ouroboros-network-framework- Ouroboros network framework
Safe HaskellSafe-Inferred




data ConnectionTableRef Source #



No connection to peer exists, attempt to create one.


A connection to the peer existed, either from another subscriber or the peer opened one towards us.


This subscriber already has counted a connection to this peer. It must try another target.

data ValencyCounter m Source #

ValencyCounter represents how many active connections we have towards a given peer. It starts out with a positive value representing a desired number of connections for a specific subscription worker. It can become negative, for example if a peer opens multiple connections to us. The vcId is unique per ConnectionTable and ensures that we won't count the same connection twice.

newConnectionTableSTMMonadSTM m ⇒ STM m (ConnectionTable m addr) Source #

Create a new ConnectionTable.

refConnectionSTM ∷ (MonadSTM m, Ord addr) ⇒ ConnectionTable m addr → addr → ConnectionDirectionValencyCounter m → STM m ConnectionTableRef Source #

Try to see if it is possible to reference an existing connection rather than creating a new one to the provied peer.

addConnection Source #


∷ ∀ m addr. (MonadSTM m, Ord addr) 
ConnectionTable m addr 
→ addr 
→ addr 
Maybe (ValencyCounter m)

Optional ValencyCounter, used by subscription worker and set to Nothing when called by a local server.

STM m () 

Insert a new connection into the ConnectionTable.

removeConnectionSTM ∷ ∀ m addr. (MonadSTM m, Ord addr) ⇒ ConnectionTable m addr → addr → addr → ConnectionDirectionSTM m () Source #

Remove a Connection.

removeConnection ∷ ∀ m addr. (MonadSTM m, Ord addr) ⇒ ConnectionTable m addr → addr → addr → ConnectionDirection → m () Source #

newValencyCounter Source #


MonadSTM m 
ConnectionTable m addr 

Desired valency, that is number of connections a subscription worker will attempt to maintain.

STM m (ValencyCounter m) 

Create a new ValencyCounter

addValencyCounterMonadSTM m ⇒ ValencyCounter m → STM m () Source #

Add a connection.

remValencyCounterMonadSTM m ⇒ ValencyCounter m → STM m () Source #

Remove a connection.

waitValencyCounterMonadSTM m ⇒ ValencyCounter m → STM m () Source #

Wait until ValencyCounter becomes positive, used for detecting when we can create new connections.

readValencyCounterMonadSTM m ⇒ ValencyCounter m → STM m Int Source #

Returns current ValencyCounter value, represent the number of additional connections that can be created. May be negative.