Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data EstablishedPeers peeraddr peerconn
- empty :: EstablishedPeers peeraddr perconn
- toMap :: EstablishedPeers peeraddr peerconn -> Map peeraddr peerconn
- toSet :: EstablishedPeers peeraddr peerconn -> Set peeraddr
- readyPeers :: Ord peeraddr => EstablishedPeers peeraddr peerconn -> Set peeraddr
- size :: EstablishedPeers peeraddr peerconn -> Int
- sizeReady :: EstablishedPeers peeraddr peerconn -> Int
- member :: Ord peeraddr => peeraddr -> EstablishedPeers peeraddr peerconn -> Bool
- insert :: Ord peeraddr => peeraddr -> peerconn -> Maybe Time -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn
- delete :: Ord peeraddr => peeraddr -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn
- deletePeers :: Ord peeraddr => Set peeraddr -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn
- setCurrentTime :: Ord peeraddr => Time -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn
- setActivateTimes :: Ord peeraddr => Map peeraddr Time -> EstablishedPeers peeraddr peerconn -> EstablishedPeers peeraddr peerconn
- minActivateTime :: Ord peeraddr => EstablishedPeers peeraddr peerconn -> (peeraddr -> Bool) -> Maybe Time
- minPeerShareTime :: Ord peeraddr => EstablishedPeers peeraddr peercon -> Maybe Time
- setPeerShareTime :: Ord peeraddr => Set peeraddr -> Time -> EstablishedPeers peeraddr peercon -> EstablishedPeers peeraddr peercon
- availableForPeerShare :: EstablishedPeers peeraddr peerconn -> Set peeraddr
- nextPeerShareTimes :: EstablishedPeers peeraddr peerconn -> OrdPSQ peeraddr Time ()
- invariant :: Ord peeraddr => EstablishedPeers peeraddr peerconn -> Bool
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
Functor (EstablishedPeers peeraddr) Source # | |
Defined in Ouroboros.Network.PeerSelection.State.EstablishedPeers 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 # | |
Defined in Ouroboros.Network.PeerSelection.State.EstablishedPeers 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)
:: 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
:: 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.