ouroboros-network
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Diffusion.Policies

Synopsis

Documentation

deactivateTimeout :: DiffTime Source #

Timeout for spsDeactivateTimeout and churn hot to warm demotions.

The maximal timeout on ChainSync (in StMustReply state) is 269s, see maxChainSyncTimeout below.

closeConnectionTimeout :: DiffTime Source #

Timeout for spsCloseConnectionTimeout.

This timeout depends on KeepAlive and TipSample timeouts. KeepAlive keeps agency most of the time, but TipSample can give away its agency for longer periods of time. Here we allow it to get 6 blocks (assuming a new block every 20s).

churnEstablishConnectionTimeout :: DiffTime Source #

Churn timeouts after 60s trying to establish a connection.

This doesn't mean the connection is terminated after it, just churns moves on.

peerMetricsConfiguration :: PeerMetricsConfiguration Source #

Number of events tracked by PeerMetrics. This corresponds to one hour of blocks on mainnet.

TODO: issue #3866

inboundPeersRetryDelay :: DiffTime Source #

Minimal delay between adding inbound peers to known set of outbound governor.

It is set to 60s, the same as the peer sharing request timeout.

maxInboundPeers :: Int Source #

Maximal number of light peers included at once.

repromoteErrorDelay :: RepromoteDelay Source #

Delay before a peer is re-promoted by the outbound-governor after an error.

optionalMerge :: Ord k => Map k a -> Map k b -> Map k (a, Maybe b) Source #

Merge two dictionaries where values of the first one are obligatory, while the second one are optional.

deadlineHotScores :: forall (m :: Type -> Type) peerAddr. (MonadSTM m, Ord peerAddr) => PeerMetrics m peerAddr -> STM m (Map peerAddr (Int, Maybe SlotNo)) Source #

The score by which simplePeerSelectionPolicy ranks hot peers for demotion: the peer's upstreamyness plus its fetchynessBlocks, with joinedPeerMetricAt as the tie-break.

mkHotDemotionPolicy Source #

Arguments

:: forall (m :: Type -> Type) peerAddr. (MonadSTM m, Ord peerAddr) 
=> StrictTVar m StdGen 
-> STM m (Map peerAddr (Int, Maybe SlotNo))

the scores, with a slot number as the tie-break, see joinedPeerMetricAt

-> HotDemotionPolicy peerAddr (STM m) 

A hot demotion policy which picks the lowest scoring peers, and returns the scores it ranked them by so that the governor can trace the decision. A peer without a score is ranked as if it scored 0 but before every peer which did, and is returned as Nothing so that the trace keeps the two apart.

simplePeerSelectionPolicy :: forall (m :: Type -> Type) peerAddr. (MonadSTM m, Ord peerAddr) => StrictTVar m StdGen -> PeerMetrics m peerAddr -> PeerSelectionPolicy peerAddr m Source #

addRand :: forall (m :: Type -> Type) peerAddr. (MonadSTM m, Ord peerAddr) => StrictTVar m StdGen -> Set peerAddr -> (peerAddr -> Word32 -> (peerAddr, Word32)) -> STM m (Map peerAddr Word32) Source #

prunePolicy :: Ord peerAddr => PrunePolicy peerAddr Source #

Sort by upstreamness and a random score.

Note: this PrunePolicy does not depend on igsConnections. We put igsPrng in InboundGovernorState only to show that we can have a PrunePolicy which depends on the InboundGovernorState as a more refined policy would do.

complexity: \(\mathcal{O}(n\log\;n)\)

TODO: complexity could be improved.