Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data KnownPeers peeraddr
- data KnownPeerInfo = KnownPeerInfo {}
- invariant :: Ord peeraddr => KnownPeers peeraddr -> Bool
- allPeers :: KnownPeers peeraddr -> Map peeraddr KnownPeerInfo
- alterKnownPeerInfo :: (Maybe PeerSharing, Maybe PeerAdvertise) -> Maybe KnownPeerInfo -> Maybe KnownPeerInfo
- empty :: KnownPeers peeraddr
- size :: KnownPeers peeraddr -> Int
- insert :: Ord peeraddr => Map peeraddr (Maybe PeerSharing, Maybe PeerAdvertise) -> KnownPeers peeraddr -> KnownPeers peeraddr
- alter :: Ord peeraddr => (Maybe KnownPeerInfo -> Maybe KnownPeerInfo) -> Set peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr
- delete :: Ord peeraddr => Set peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr
- toSet :: KnownPeers peeraddr -> Set peeraddr
- member :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Bool
- setCurrentTime :: Ord peeraddr => Time -> KnownPeers peeraddr -> KnownPeers peeraddr
- incrementFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> (Int, KnownPeers peeraddr)
- resetFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr
- lookupFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Maybe Int
- lookupTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Maybe Bool
- setTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr
- clearTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr
- setSuccessfulConnectionFlag :: Ord peeraddr => Set peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr
- minConnectTime :: Ord peeraddr => KnownPeers peeraddr -> (peeraddr -> Bool) -> Maybe Time
- setConnectTimes :: Ord peeraddr => Map peeraddr Time -> KnownPeers peeraddr -> KnownPeers peeraddr
- availableToConnect :: KnownPeers peeraddr -> Set peeraddr
- canPeerShareRequest :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Bool
- getPeerSharingRequestPeers :: Ord peeraddr => Set peeraddr -> KnownPeers peeraddr -> Set peeraddr
- canSharePeers :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Bool
- getPeerSharingResponsePeers :: KnownPeers peeraddr -> Set peeraddr
Types
data KnownPeers peeraddr Source #
The set of known peers. To a first approximation it can be thought of as
a Set
of peeraddr
.
It has one special feature:
- It tracks the subset of peers that we are happy to publish in reply to peer share requests to our node. It supports random sampling from this set.
Instances
Show peeraddr => Show (KnownPeers peeraddr) Source # | |
Defined in Ouroboros.Network.PeerSelection.State.KnownPeers showsPrec :: Int -> KnownPeers peeraddr -> ShowS # show :: KnownPeers peeraddr -> String # showList :: [KnownPeers peeraddr] -> ShowS # | |
Ord peeraddr => Eq (KnownPeers peeraddr) Source # | |
Defined in Ouroboros.Network.PeerSelection.State.KnownPeers (==) :: KnownPeers peeraddr -> KnownPeers peeraddr -> Bool # (/=) :: KnownPeers peeraddr -> KnownPeers peeraddr -> Bool # |
data KnownPeerInfo Source #
KnownPeerInfo | |
|
Instances
Show KnownPeerInfo Source # | |
Defined in Ouroboros.Network.PeerSelection.State.KnownPeers showsPrec :: Int -> KnownPeerInfo -> ShowS # show :: KnownPeerInfo -> String # showList :: [KnownPeerInfo] -> ShowS # | |
Eq KnownPeerInfo Source # | |
Defined in Ouroboros.Network.PeerSelection.State.KnownPeers (==) :: KnownPeerInfo -> KnownPeerInfo -> Bool # (/=) :: KnownPeerInfo -> KnownPeerInfo -> Bool # |
allPeers :: KnownPeers peeraddr -> Map peeraddr KnownPeerInfo Source #
All the known peers.
KnownPeerInfo operations
alterKnownPeerInfo :: (Maybe PeerSharing, Maybe PeerAdvertise) -> Maybe KnownPeerInfo -> Maybe KnownPeerInfo Source #
Basic container operations
empty :: KnownPeers peeraddr Source #
size :: KnownPeers peeraddr -> Int Source #
insert :: Ord peeraddr => Map peeraddr (Maybe PeerSharing, Maybe PeerAdvertise) -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
This inserts a map of peers with its respective peer sharing, peer advertise and ledger flags into the known peers set.
Please note that if in the map there's an entry for a peer already present
in the known peers set, then its values will only be overwritten if they
are a Just
. Otherwise the current information will be preserved. On the
other hand if there's an entry for a peer that isn't a member of the known
peer set, the Nothing
values will default to PeerSharingDisabled
,
DoNotAdvertisePeer
and IsNotLedgerPeer
, respectively, unless a Just
value is used.
alter :: Ord peeraddr => (Maybe KnownPeerInfo -> Maybe KnownPeerInfo) -> Set peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
delete :: Ord peeraddr => Set peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
toSet :: KnownPeers peeraddr -> Set peeraddr Source #
O(n)
Special operations
setCurrentTime :: Ord peeraddr => Time -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
incrementFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> (Int, KnownPeers peeraddr) Source #
resetFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
lookupFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Maybe Int Source #
lookupTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Maybe Bool Source #
setTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
clearTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
setSuccessfulConnectionFlag :: Ord peeraddr => Set peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
Tracking when we can (re)connect
:: Ord peeraddr | |
=> KnownPeers peeraddr | |
-> (peeraddr -> Bool) | a predicate which describes the peers to take into account |
-> Maybe Time |
setConnectTimes :: Ord peeraddr => Map peeraddr Time -> KnownPeers peeraddr -> KnownPeers peeraddr Source #
availableToConnect :: KnownPeers peeraddr -> Set peeraddr Source #
The subset of known peers that we would be allowed to try to establish a connection to now. This is because we have not connected with them before or because any failure backoff time has expired.
Selecting peers to ask
canPeerShareRequest :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Bool Source #
getPeerSharingRequestPeers :: Ord peeraddr => Set peeraddr -> KnownPeers peeraddr -> Set peeraddr Source #
Filter peers available for Peer Sharing requests, according to their
PeerSharing
information
Selecting peers to share
canSharePeers :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Bool Source #
getPeerSharingResponsePeers :: KnownPeers peeraddr -> Set peeraddr Source #
Filter peers available for Peer Sharing replies, according to their
PeerAdvertise
information