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

Ouroboros.Network.PeerSelection.State.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 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

Instances details
Show peeraddr ⇒ Show (KnownPeers peeraddr) Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.State.KnownPeers

Methods

showsPrecIntKnownPeers peeraddr → ShowS #

showKnownPeers peeraddr → String #

showList ∷ [KnownPeers peeraddr] → ShowS #

Ord peeraddr ⇒ Eq (KnownPeers peeraddr) Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.State.KnownPeers

Methods

(==)KnownPeers peeraddr → KnownPeers peeraddr → Bool #

(/=)KnownPeers peeraddr → KnownPeers peeraddr → Bool #

data KnownPeerInfo Source #

Constructors

KnownPeerInfo 

Fields

  • knownPeerFailCount ∷ !Int

    The current number of consecutive connection attempt failures. This is reset as soon as there is a successful connection.

    It is used to implement the exponential backoff strategy and may also be used by policies to select peers to forget.

  • knownPeerTepid ∷ !Bool

    Indicates if the peer was hot but then got demoted.

    It is set on the hot to warm promotion and reset on cold to warm, thus it can be present for warm or cold peers. It's purpose is to provide information to demotion policies.

    It is also used as useful information for the Peer Selection Governor when deciding which peers to share when Peer Sharing.

  • knownPeerSharing ∷ !PeerSharing

    Indicates current remote Peer Willingness information.

    If a connection with this address hasn't been established we won't have any information about this particular flag

    It is used by the Peer Sharing logic to decide if we should share/ask about/to this peer's address to others.

  • knownPeerAdvertise ∷ !PeerAdvertise

    Indicates current local Peer Willingness information.

    If this address didn't come from a local configuration then this value is set to DoAdvertise by default.

    It is used by the Peer Sharing logic to decide if we should share about this peer's address to others.

  • knownSuccessfulConnection ∷ !Bool

    Indicates if the node managed to connect to the peer at some point in time.

    This differs from the tepid flag in a way that this flag will be set/enabled if we established a successful connection with this peer. It won't be unset after this.

invariantOrd peeraddr ⇒ KnownPeers peeraddr → Bool Source #

allPeersKnownPeers peeraddr → Map peeraddr KnownPeerInfo Source #

All the known peers.

KnownPeerInfo operations

Basic container operations

emptyKnownPeers peeraddr Source #

sizeKnownPeers peeraddr → Int Source #

insertOrd 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 NoPeerSharing, DoNotAdvertisePeer and IsNotLedgerPeer, respectively, unless a Just value is used.

alterOrd peeraddr ⇒ (Maybe KnownPeerInfoMaybe KnownPeerInfo) → Set peeraddr → KnownPeers peeraddr → KnownPeers peeraddr Source #

deleteOrd peeraddr ⇒ Set peeraddr → KnownPeers peeraddr → KnownPeers peeraddr Source #

toSetKnownPeers peeraddr → Set peeraddr Source #

O(n)

memberOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → Bool Source #

Special operations

setCurrentTimeOrd peeraddr ⇒ TimeKnownPeers peeraddr → KnownPeers peeraddr Source #

incrementFailCountOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → (Int, KnownPeers peeraddr) Source #

resetFailCountOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → KnownPeers peeraddr Source #

lookupFailCountOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → Maybe Int Source #

lookupTepidFlagOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → Maybe Bool Source #

setTepidFlagOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → KnownPeers peeraddr Source #

clearTepidFlagOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → KnownPeers peeraddr Source #

setSuccessfulConnectionFlagOrd peeraddr ⇒ Set peeraddr → KnownPeers peeraddr → KnownPeers peeraddr Source #

Tracking when we can (re)connect

minConnectTime Source #

Arguments

Ord peeraddr 
KnownPeers peeraddr 
→ (peeraddr → Bool)

a predicate which describes the peers to take into account

Maybe Time 

setConnectTimesOrd peeraddr ⇒ Map peeraddr TimeKnownPeers peeraddr → KnownPeers peeraddr Source #

availableToConnectKnownPeers 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

canPeerShareRequestOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → Bool Source #

getPeerSharingRequestPeersOrd peeraddr ⇒ Set peeraddr → KnownPeers peeraddr → Set peeraddr Source #

Filter peers available for Peer Sharing requests, according to their PeerSharing information

Selecting peers to share

canSharePeersOrd peeraddr ⇒ peeraddr → KnownPeers peeraddr → Bool Source #

getPeerSharingResponsePeersKnownPeers peeraddr → Set peeraddr Source #

Filter peers available for Peer Sharing replies, according to their PeerAdvertise information