ouroboros-network
Safe HaskellNone
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

showsPrec :: Int -> EstablishedPeers peeraddr peerconn -> ShowS #

show :: EstablishedPeers peeraddr peerconn -> String #

showList :: [EstablishedPeers peeraddr peerconn] -> ShowS #

empty :: EstablishedPeers peeraddr perconn Source #

toMap :: EstablishedPeers peeraddr peerconn -> Map peeraddr peerconn Source #

O(1)

toSet :: EstablishedPeers peeraddr peerconn -> Set peeraddr Source #

O(n)

readyPeers :: Ord 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

size :: EstablishedPeers peeraddr peerconn -> Int Source #

The number of established peers. The size of allPeers

O(1)

sizeReady :: EstablishedPeers peeraddr peerconn -> Int Source #

The number of ready peers. The size of readyPeers

O(1)

member :: Ord 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.

delete :: Ord peeraddr => peeraddr -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn Source #

deletePeers :: Ord peeraddr => Set peeraddr -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn Source #

Bulk delete of peers from 'EstablishedPeers.

Special operations

setCurrentTime :: Ord peeraddr => Time -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn Source #

setActivateTimes :: Ord peeraddr => Map peeraddr Time -> EstablishedPeers 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

minPeerShareTime :: Ord 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.

setPeerShareTime :: Ord peeraddr => Set peeraddr -> Time -> EstablishedPeers peeraddr peercon -> EstablishedPeers peeraddr peercon Source #

availableForPeerShare :: EstablishedPeers 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.

nextPeerShareTimes :: EstablishedPeers 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.

invariant :: Ord peeraddr => EstablishedPeers peeraddr peerconn -> Bool Source #