Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data DomainAccessPoint = DomainAccessPoint {
- dapDomain :: !Domain
- dapPortNumber :: !PortNumber
- data IP
- data LedgerPeers
- getLedgerPeers :: forall (m :: Type -> Type). MonadSTM m => LedgerPeersConsensusInterface m -> AfterSlot -> STM m LedgerPeers
- data RelayAccessPoint where
- newtype PoolStake = PoolStake {}
- newtype AccPoolStake = AccPoolStake {}
- data TraceLedgerPeers
- = PickedBigLedgerPeer RelayAccessPoint AccPoolStake PoolStake
- | PickedLedgerPeer RelayAccessPoint AccPoolStake PoolStake
- | PickedBigLedgerPeers NumberOfPeers [RelayAccessPoint]
- | PickedLedgerPeers NumberOfPeers [RelayAccessPoint]
- | FetchingNewLedgerState Int Int
- | TraceLedgerPeersDomains [DomainAccessPoint]
- | TraceLedgerPeersResult Domain [(IP, TTL)]
- | TraceLedgerPeersFailure Domain DNSError
- | DisabledLedgerPeers
- | TraceUseLedgerPeers UseLedgerPeers
- | WaitingOnRequest
- | RequestForPeers NumberOfPeers
- | ReusingLedgerState Int DiffTime
- | FallingBackToPublicRootPeers
- | NotEnoughBigLedgerPeers NumberOfPeers Int
- | NotEnoughLedgerPeers NumberOfPeers Int
- | UsingBigLedgerPeerSnapshot
- newtype NumberOfPeers = NumberOfPeers {}
- data LedgerPeersKind
- data StakeMapOverSource = StakeMapOverSource {}
- accPoolStake :: [(PoolStake, NonEmpty RelayAccessPoint)] -> Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint)
- accumulateBigLedgerStake :: [(PoolStake, NonEmpty RelayAccessPoint)] -> [(AccPoolStake, (PoolStake, NonEmpty RelayAccessPoint))]
- accBigPoolStakeMap :: [(PoolStake, NonEmpty RelayAccessPoint)] -> Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint)
- bigLedgerPeerQuota :: AccPoolStake
- stakeMapWithSlotOverSource :: StakeMapOverSource -> (Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint), Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint), Maybe SlotNo)
- data WithLedgerPeersArgs (m :: Type -> Type) = WithLedgerPeersArgs {}
- withLedgerPeers :: forall peerAddr resolver exception m a. (MonadAsync m, MonadThrow m, MonadMonotonicTime m, Exception exception, Ord peerAddr) => PeerActionsDNS peerAddr resolver exception m -> WithLedgerPeersArgs m -> ((NumberOfPeers -> LedgerPeersKind -> m (Maybe (Set peerAddr, DiffTime))) -> Async m Void -> m a) -> m a
- module Ouroboros.Network.PeerSelection.LedgerPeers.Type
- data LedgerPeers
- data TraceLedgerPeers
- = PickedBigLedgerPeer RelayAccessPoint AccPoolStake PoolStake
- | PickedLedgerPeer RelayAccessPoint AccPoolStake PoolStake
- | PickedBigLedgerPeers NumberOfPeers [RelayAccessPoint]
- | PickedLedgerPeers NumberOfPeers [RelayAccessPoint]
- | FetchingNewLedgerState Int Int
- | TraceLedgerPeersDomains [DomainAccessPoint]
- | TraceLedgerPeersResult Domain [(IP, TTL)]
- | TraceLedgerPeersFailure Domain DNSError
- | DisabledLedgerPeers
- | TraceUseLedgerPeers UseLedgerPeers
- | WaitingOnRequest
- | RequestForPeers NumberOfPeers
- | ReusingLedgerState Int DiffTime
- | FallingBackToPublicRootPeers
- | NotEnoughBigLedgerPeers NumberOfPeers Int
- | NotEnoughLedgerPeers NumberOfPeers Int
- | UsingBigLedgerPeerSnapshot
- newtype NumberOfPeers = NumberOfPeers {}
- data IsLedgerPeer
- 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))
Documentation
data DomainAccessPoint #
A product of a Domain
and PortNumber
. After resolving the
domain we will use the PortNumber
to form SockAddr
.
Instances
A unified IP data for IPv4
and IPv6
.
To create this, use the data constructors. Or use read
"192.0.2.1"
:: IP
, for example. Also, "192.0.2.1"
can be used as literal with OverloadedStrings.
>>>
(read "192.0.2.1" :: IP) == IPv4 (read "192.0.2.1" :: IPv4)
True>>>
(read "2001:db8:00:00:00:00:00:01" :: IP) == IPv6 (read "2001:db8:00:00:00:00:00:01" :: IPv6)
True
Instances
Data IP | |||||
Defined in Data.IP.Addr gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IP -> c IP # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IP # dataTypeOf :: IP -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IP) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IP) # gmapT :: (forall b. Data b => b -> b) -> IP -> IP # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IP -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IP -> r # gmapQ :: (forall d. Data d => d -> u) -> IP -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> IP -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IP -> m IP # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IP -> m IP # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IP -> m IP # | |||||
IsString IP | |||||
Defined in Data.IP.Addr fromString :: String -> IP # | |||||
Enum IP | |||||
Generic IP | |||||
Defined in Data.IP.Addr
| |||||
Read IP | |||||
Show IP | |||||
Eq IP | Equality over IP addresses. Correctly compare IPv4 and IPv4-embedded-in-IPv6 addresses.
| ||||
Ord IP | |||||
type Rep IP | |||||
Defined in Data.IP.Addr type Rep IP = D1 ('MetaData "IP" "Data.IP.Addr" "iproute-1.7.12-d41755f9302e1993407507681e30b3bc13ae12497cd5c62c21eb74709e2da91f" 'False) (C1 ('MetaCons "IPv4" 'PrefixI 'True) (S1 ('MetaSel ('Just "ipv4") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedUnpack) (Rec0 IPv4)) :+: C1 ('MetaCons "IPv6" 'PrefixI 'True) (S1 ('MetaSel ('Just "ipv6") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 IPv6))) |
data LedgerPeers Source #
Ledger Peer request result
LedgerPeers | |
| |
BeforeSlot | No result because the node is still before the configured UseLedgerAfter slot number |
Instances
Show LedgerPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> LedgerPeers -> ShowS # show :: LedgerPeers -> String # showList :: [LedgerPeers] -> ShowS # | |
Eq LedgerPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common (==) :: LedgerPeers -> LedgerPeers -> Bool # (/=) :: LedgerPeers -> LedgerPeers -> Bool # |
getLedgerPeers :: forall (m :: Type -> Type). MonadSTM m => LedgerPeersConsensusInterface m -> AfterSlot -> STM m LedgerPeers Source #
Internal API to deal with UseLedgerAfter
configuration
option
Receiving the LedgerPeersConsensusInterface
we are able to compute a
function that given a SlotNo
will give us LedgerPeers
according to the
following invariants:
BeforeSlot
is returned iff the latest slot is before theslotNo
;- 'LedgerPeers lsj peers' is returned iff the latest slot is after the
slotNo
.
data RelayAccessPoint #
A relay can have either an IP address and a port number or a domain with a port number
pattern RelayDomainAccessPoint :: DomainAccessPoint -> RelayAccessPoint |
|
Instances
The relative stake of a stakepool in relation to the total amount staked. A value in the [0, 1] range.
newtype AccPoolStake #
The accumulated relative stake of a stake pool, like PoolStake but it also includes the relative stake of all preceding pools. A value in the range [0, 1].
Instances
data TraceLedgerPeers Source #
Trace LedgerPeers events.
Instances
Show TraceLedgerPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> TraceLedgerPeers -> ShowS # show :: TraceLedgerPeers -> String # showList :: [TraceLedgerPeers] -> ShowS # |
newtype NumberOfPeers Source #
Instances
Show NumberOfPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> NumberOfPeers -> ShowS # show :: NumberOfPeers -> String # showList :: [NumberOfPeers] -> ShowS # |
data LedgerPeersKind #
Which ledger peers to pick.
Instances
Show LedgerPeersKind | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Type showsPrec :: Int -> LedgerPeersKind -> ShowS # show :: LedgerPeersKind -> String # showList :: [LedgerPeersKind] -> ShowS # |
data StakeMapOverSource Source #
Arguments record to stakeMapWithSlotOverSource function
Instances
Show StakeMapOverSource Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers showsPrec :: Int -> StakeMapOverSource -> ShowS # show :: StakeMapOverSource -> String # showList :: [StakeMapOverSource] -> ShowS # |
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).
accumulateBigLedgerStake :: [(PoolStake, NonEmpty RelayAccessPoint)] -> [(AccPoolStake, (PoolStake, NonEmpty RelayAccessPoint))] #
Sort ascendingly a given list of pools with stake,
and tag each one with cumulative stake, with a cutoff
at bigLedgerPeerQuota
accBigPoolStakeMap :: [(PoolStake, NonEmpty RelayAccessPoint)] -> Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint) Source #
Take the result of accBigPoolStake
and turn it into
bigLedgerPeerQuota :: AccPoolStake #
The total accumulated stake of big ledger peers.
stakeMapWithSlotOverSource :: StakeMapOverSource -> (Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint), Map AccPoolStake (PoolStake, NonEmpty RelayAccessPoint), Maybe SlotNo) Source #
Build up a stake map to sample ledger peers from. The SlotNo, if different from 0, indicates that the maps are the stake pools from the snapshot taken from the particular slot number.
DNS based provider for ledger root peers
data WithLedgerPeersArgs (m :: Type -> Type) Source #
Argument record for withLedgerPeers
WithLedgerPeersArgs | |
|
withLedgerPeers :: forall peerAddr resolver exception m a. (MonadAsync m, MonadThrow m, MonadMonotonicTime m, Exception exception, Ord peerAddr) => PeerActionsDNS peerAddr resolver exception m -> WithLedgerPeersArgs 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.
data LedgerPeers Source #
Ledger Peer request result
LedgerPeers | |
| |
BeforeSlot | No result because the node is still before the configured UseLedgerAfter slot number |
Instances
Show LedgerPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> LedgerPeers -> ShowS # show :: LedgerPeers -> String # showList :: [LedgerPeers] -> ShowS # | |
Eq LedgerPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common (==) :: LedgerPeers -> LedgerPeers -> Bool # (/=) :: LedgerPeers -> LedgerPeers -> Bool # |
data TraceLedgerPeers Source #
Trace LedgerPeers events.
Instances
Show TraceLedgerPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> TraceLedgerPeers -> ShowS # show :: TraceLedgerPeers -> String # showList :: [TraceLedgerPeers] -> ShowS # |
newtype NumberOfPeers Source #
Instances
Show NumberOfPeers Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> NumberOfPeers -> ShowS # show :: NumberOfPeers -> String # showList :: [NumberOfPeers] -> ShowS # |
data IsLedgerPeer Source #
Identifies a peer as coming from ledger or not
IsLedgerPeer | a ledger peer. |
IsNotLedgerPeer |
Instances
Show IsLedgerPeer Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common showsPrec :: Int -> IsLedgerPeer -> ShowS # show :: IsLedgerPeer -> String # showList :: [IsLedgerPeer] -> ShowS # | |
Eq IsLedgerPeer Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers.Common (==) :: IsLedgerPeer -> IsLedgerPeer -> Bool # (/=) :: IsLedgerPeer -> IsLedgerPeer -> Bool # |
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.