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

Ouroboros.Network.PeerSelection.LedgerPeers

Synopsis

Ledger Peers specific data types

data IsLedgerPeer Source #

Identifies a peer as coming from ledger or not

Constructors

IsLedgerPeer

a ledger peer.

IsNotLedgerPeer 

newtype LedgerPeersConsensusInterface m Source #

Constructors

LedgerPeersConsensusInterface 

Fields

data LedgerPeersKind Source #

Which ledger peers to pick.

Ledger Peers specific functions

accPoolStake :: [(PoolStake, NonEmpty RelayAccessPoint)] -> Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint) Source #

Convert a list of pools with stake to a Map keyed on the accumulated stake. Consensus provides a list of pairs of relative stake and corresponding relays for all usable registered pools. By creating a Map keyed on the AccPoolStake that is the sum of the pool's relative stake and the stake of all preceding pools we can support weighted random selection in O(log n) time by taking advantage of Map.lookupGE (returns the smallest key greater or equal to the provided value).

accBigPoolStake :: [(PoolStake, NonEmpty RelayAccessPoint)] -> Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint) Source #

Convert a list of pools with stake to a Map keyed on the accumulated stake which only contains big ledger peers, e.g. largest ledger peers which cumulatively control 90% of stake.

bigLedgerPeerQuota :: AccPoolStake Source #

The total accumulated stake of big ledger peers.

DNS based provider for ledger root peers

withLedgerPeers :: forall peerAddr resolver exception m a. (MonadAsync m, MonadThrow m, MonadMonotonicTime m, Exception exception, Ord peerAddr) => StdGen -> DNSSemaphore m -> (IP -> PortNumber -> peerAddr) -> Tracer m TraceLedgerPeers -> STM m UseLedgerAfter -> LedgerPeersConsensusInterface m -> DNSActions resolver exception m -> ((NumberOfPeers -> LedgerPeersKind -> m (Maybe (Set peerAddr, DiffTime))) -> Async m Void -> m a) -> m a Source #

For a LedgerPeers worker thread and submit request and receive responses.

Re-exports

data IsLedgerPeer Source #

Identifies a peer as coming from ledger or not

Constructors

IsLedgerPeer

a ledger peer.

IsNotLedgerPeer 

data TraceLedgerPeers Source #

Trace LedgerPeers events.

Constructors

PickedBigLedgerPeer RelayAccessPoint AccPoolStake PoolStake

Trace for a significant ledger peer picked with accumulated and relative stake of its pool.

PickedLedgerPeer RelayAccessPoint AccPoolStake PoolStake

Trace for a ledger peer picked with accumulated and relative stake of its pool.

PickedBigLedgerPeers NumberOfPeers [RelayAccessPoint] 
PickedLedgerPeers NumberOfPeers [RelayAccessPoint]

Trace for the number of peers and we wanted to pick and the list of peers picked.

FetchingNewLedgerState Int Int

Trace for fetching a new list of peers from the ledger. The first Int is the number of ledger peers returned the latter is the number of big ledger peers.

TraceLedgerPeersDomains [DomainAccessPoint] 
TraceLedgerPeersResult Domain [(IP, TTL)] 
TraceLedgerPeersFailure Domain DNSError 
DisabledLedgerPeers

Trace for when getting peers from the ledger is disabled, that is DontUseLedger.

TraceUseLedgerAfter UseLedgerAfter

Trace UseLedgerAfter value

WaitingOnRequest 
RequestForPeers NumberOfPeers 
ReusingLedgerState Int DiffTime 
FallingBackToPublicRootPeers 
NotEnoughBigLedgerPeers NumberOfPeers Int 
NotEnoughLedgerPeers NumberOfPeers Int 

Internal only exported for testing purposes

resolveLedgerPeers :: forall m peerAddr resolver exception. (Ord peerAddr, MonadThrow m, MonadAsync m, Exception exception) => Tracer m TraceLedgerPeers -> (IP -> PortNumber -> peerAddr) -> DNSSemaphore m -> ResolvConf -> DNSActions resolver exception m -> [DomainAccessPoint] -> m (Map DomainAccessPoint (Set peerAddr)) Source #

Provides DNS resolution functionality.

Concurrently resolve DNS names, respecting the maxDNSConcurrency limit.