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

Ouroboros.Network.PeerSelection.Governor.EstablishedPeers

Synopsis

Documentation

belowTarget ∷ ∀ peeraddr peerconn m. (Alternative (STM m), MonadSTM m, Ord peeraddr) ⇒ PeerSelectionActions peeraddr peerconn m → MkGuardedDecision peeraddr peerconn m Source #

If we are below the target of warm peers we promote cold peers according to policyPickColdPeersToPromote.

There are two targets we are trying to hit here:

  1. a target for the overall number of established peers; and
  2. the target that all local root peers are established peers.

These two targets overlap: the conditions and the actions overlap since local root peers are also known peers. Since they overlap, the order in which we consider these targets is important. We consider the local peers target before the target for promoting other peers.

We will always try to establish connections to the local root peers, even if that would put us over target for the number of established peers. If we do go over target then the action to demote will be triggered. The demote action never picks local root peers.

aboveTarget ∷ ∀ peeraddr peerconn m. (Alternative (STM m), MonadSTM m, Ord peeraddr) ⇒ PeerSelectionActions peeraddr peerconn m → MkGuardedDecision peeraddr peerconn m Source #

If we are above the target of established peers we demote some of the warm peers to the cold state, according to policyPickWarmPeersToDemote.