ouroboros-network-0.1.0.1: A networking layer for the Ouroboros blockchain protocol
Safe Haskell Safe-Inferred
Language Haskell2010

Ouroboros.Network.PeerSelection.KnownPeers

Synopsis

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 two special features:

  • It tracks which peers we are permitted to gossip with now, or for peers we cannot gossip with now the time at which we would next be allowed to do so.
  • It tracks the subset of peers that we are happy to publish in reply to gossip requests to our node. It supports random sampling from this set.

Basic container operations

insert :: Ord peeraddr => 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)

member :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> Bool Source #

Special operations

incrementFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> ( Int , KnownPeers peeraddr) Source #

resetFailCount :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #

setTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #

clearTepidFlag :: Ord peeraddr => peeraddr -> KnownPeers peeraddr -> KnownPeers peeraddr Source #

Tracking when we can gossip

minGossipTime :: Ord peeraddr => KnownPeers peeraddr -> Maybe Time Source #

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

setGossipTime :: Ord peeraddr => Set peeraddr -> Time -> KnownPeers peeraddr -> KnownPeers peeraddr Source #

availableForGossip :: KnownPeers peeraddr -> Set peeraddr Source #

The subset of known peers that we would be allowed to gossip with now. This is because we have not gossiped with them recently.

Tracking when we can (re)connect

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.