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

Ouroboros.Network.PeerSelection.State.EstablishedPeers

Synopsis

Documentation

data EstablishedPeers peeraddr peerconn Source #

The set of established peers. To a first approximation it can be thought of as a Set of peeraddr.

It has one special feature:

  • It tracks which peers we are permitted to ask for peers now, or for peers we cannot issue share requests with now the time at which we would next be allowed to do so.

Instances

Instances details
Functor (EstablishedPeers peeraddr) Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.State.EstablishedPeers

Methods

fmap ∷ (a → b) → EstablishedPeers peeraddr a → EstablishedPeers peeraddr b #

(<$) ∷ a → EstablishedPeers peeraddr b → EstablishedPeers peeraddr a #

(Show peeraddr, Show peerconn) ⇒ Show (EstablishedPeers peeraddr peerconn) Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.State.EstablishedPeers

Methods

showsPrecIntEstablishedPeers peeraddr peerconn → ShowS #

showEstablishedPeers peeraddr peerconn → String #

showList ∷ [EstablishedPeers peeraddr peerconn] → ShowS #

emptyEstablishedPeers peeraddr perconn Source #

toMapEstablishedPeers peeraddr peerconn → Map peeraddr peerconn Source #

O(1)

toSetEstablishedPeers peeraddr peerconn → Set peeraddr Source #

O(n)

readyPeersOrd peeraddr ⇒ EstablishedPeers peeraddr peerconn → Set peeraddr Source #

Map of established peers that are either active or ready to be promoted to active.

O(n log m), for n not-ready peers, and m established peers

sizeEstablishedPeers peeraddr peerconn → Int Source #

The number of established peers. The size of allPeers

O(1)

sizeReadyEstablishedPeers peeraddr peerconn → Int Source #

The number of ready peers. The size of readyPeers

O(1)

memberOrd peeraddr ⇒ peeraddr → EstablishedPeers peeraddr peerconn → Bool Source #

insert Source #

Arguments

Ord peeraddr 
⇒ peeraddr 
→ peerconn 
Maybe Time

When to first peershare with peer, Nothing means never

EstablishedPeers peeraddr peerconn 
EstablishedPeers peeraddr peerconn 

Insert a peer into EstablishedPeers.

deleteOrd peeraddr ⇒ peeraddr → EstablishedPeers peeraddr peerconn → EstablishedPeers peeraddr peerconn Source #

deletePeersOrd peeraddr ⇒ Set peeraddr → EstablishedPeers peeraddr peerconn → EstablishedPeers peeraddr peerconn Source #

Bulk delete of peers from 'EstablishedPeers.

Special operations

setCurrentTimeOrd peeraddr ⇒ TimeEstablishedPeers peeraddr peerconn → EstablishedPeers peeraddr peerconn Source #

setActivateTimesOrd peeraddr ⇒ Map peeraddr TimeEstablishedPeers peeraddr peerconn → EstablishedPeers peeraddr peerconn Source #

Tracking when we can (re)activate

minActivateTime Source #

Arguments

Ord peeraddr 
EstablishedPeers peeraddr peerconn 
→ (peeraddr → Bool)

a predicate which describes the peers to take into account

Maybe Time 

Find smallest activation time for a peer belonging to a given set.

Tracking when we can peer share

minPeerShareTimeOrd peeraddr ⇒ EstablishedPeers peeraddr peercon → Maybe Time Source #

The first time that a peer will become available for peer sharing. If peers are already available for peer share, or there are no peers at all then the result is Nothing.

setPeerShareTimeOrd peeraddr ⇒ Set peeraddr → TimeEstablishedPeers peeraddr peercon → EstablishedPeers peeraddr peercon Source #

availableForPeerShareEstablishedPeers peeraddr peerconn → Set peeraddr Source #

The subset of established peers that we would be allowed to peer share with now. This is because we have not peer shared with them recently.

NOTE that this is the set of available peers one would be able to perform peer sharing _now_, it doesn't mean they are 100% eligible. This will depend on other factors like the peer's PeerSharing value.

nextPeerShareTimesEstablishedPeers peeraddr peerconn → OrdPSQ peeraddr Time () Source #

The subset of established peers that we cannot peer share with now. It keeps track of the next time we are allowed to peer share with them.

invariantOrd peeraddr ⇒ EstablishedPeers peeraddr peerconn → Bool Source #