Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
-
data
DomainAccessPoint
=
DomainAccessPoint
{
- dapDomain :: ! Domain
- dapPortNumber :: ! PortNumber
- data IP
-
newtype
LedgerPeersConsensusInterface
m =
LedgerPeersConsensusInterface
{
- lpGetPeers :: SlotNo -> STM m ( Maybe [( PoolStake , NonEmpty RelayAccessPoint )])
-
data
RelayAccessPoint
where
- RelayAccessDomain ! Domain ! PortNumber
- RelayAccessAddress ! IP ! PortNumber
- pattern RelayDomainAccessPoint :: DomainAccessPoint -> RelayAccessPoint
- newtype PoolStake = PoolStake { }
- newtype AccPoolStake = AccPoolStake { }
-
data
TraceLedgerPeers
- = PickedPeer RelayAccessPoint AccPoolStake PoolStake
- | PickedPeers NumberOfPeers [ RelayAccessPoint ]
- | FetchingNewLedgerState Int
- | DisabledLedgerPeers
- | TraceUseLedgerAfter UseLedgerAfter
- | WaitingOnRequest
- | RequestForPeers NumberOfPeers
- | ReusingLedgerState Int DiffTime
- | FallingBackToBootstrapPeers
- newtype NumberOfPeers = NumberOfPeers Word16
- accPoolStake :: [( PoolStake , NonEmpty RelayAccessPoint )] -> Map AccPoolStake ( PoolStake , NonEmpty RelayAccessPoint )
- withLedgerPeers :: forall peerAddr m a. ( MonadAsync m, MonadTime m, Ord peerAddr) => StdGen -> ( IP -> PortNumber -> peerAddr) -> Tracer m TraceLedgerPeers -> STM m UseLedgerAfter -> LedgerPeersConsensusInterface m -> ([ DomainAccessPoint ] -> m ( Map DomainAccessPoint ( Set peerAddr))) -> (( NumberOfPeers -> m ( Maybe ( Set peerAddr, DiffTime ))) -> Async m Void -> m a) -> m a
- data UseLedgerAfter
- data PortNumber
Documentation
data DomainAccessPoint Source #
A product of a
Domain
and
PortNumber
. After resolving the
domain we will use the
PortNumber
to form
SockAddr
.
DomainAccessPoint | |
|
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
Enum IP | |
Defined in Data.IP.Addr |
|
Eq IP |
Equality over IP addresses. Correctly compare IPv4 and IPv4-embedded-in-IPv6 addresses.
|
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 Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c IP Source # toConstr :: IP -> Constr Source # dataTypeOf :: IP -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c IP ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c IP ) Source # gmapT :: ( forall b. Data b => b -> b) -> IP -> IP Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> IP -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> IP -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> IP -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> IP -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> IP -> m IP Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> IP -> m IP Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> IP -> m IP Source # |
|
Ord IP | |
Read IP | |
Show IP | |
IsString IP | |
Defined in Data.IP.Addr fromString :: String -> IP Source # |
|
Generic IP | |
type Rep IP | |
Defined in Data.IP.Addr
type
Rep
IP
=
D1
('
MetaData
"IP" "Data.IP.Addr" "iproute-1.7.12-7531Frr8UW3EGpk43IP3fV" '
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
)))
|
newtype LedgerPeersConsensusInterface m Source #
LedgerPeersConsensusInterface | |
|
data RelayAccessPoint Source #
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.
Instances
Eq PoolStake Source # | |
Fractional PoolStake Source # | |
Num PoolStake Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers (+) :: PoolStake -> PoolStake -> PoolStake Source # (-) :: PoolStake -> PoolStake -> PoolStake Source # (*) :: PoolStake -> PoolStake -> PoolStake Source # negate :: PoolStake -> PoolStake Source # abs :: PoolStake -> PoolStake Source # signum :: PoolStake -> PoolStake Source # fromInteger :: Integer -> PoolStake Source # |
|
Ord PoolStake Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers |
|
Show PoolStake Source # | |
NFData PoolStake Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers |
newtype AccPoolStake Source #
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.
PickedPeer RelayAccessPoint AccPoolStake PoolStake |
Trace for a peer picked with accumulated and relative stake of its pool. |
PickedPeers NumberOfPeers [ RelayAccessPoint ] |
Trace for the number of peers we wanted to pick and the list of peers picked. |
FetchingNewLedgerState Int |
Trace for fetching a new list of peers from the ledger. Int is the number of peers returned. |
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 | |
FallingBackToBootstrapPeers |
Instances
newtype NumberOfPeers Source #
Instances
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).
withLedgerPeers :: forall peerAddr m a. ( MonadAsync m, MonadTime m, Ord peerAddr) => StdGen -> ( IP -> PortNumber -> peerAddr) -> Tracer m TraceLedgerPeers -> STM m UseLedgerAfter -> LedgerPeersConsensusInterface m -> ([ DomainAccessPoint ] -> m ( Map DomainAccessPoint ( Set peerAddr))) -> (( NumberOfPeers -> m ( Maybe ( Set peerAddr, DiffTime ))) -> Async m Void -> m a) -> m a Source #
For a LederPeers worker thread and submit request and receive responses.
data UseLedgerAfter Source #
Only use the ledger after the given slot number.
Instances
Eq UseLedgerAfter Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers (==) :: UseLedgerAfter -> UseLedgerAfter -> Bool Source # (/=) :: UseLedgerAfter -> UseLedgerAfter -> Bool Source # |
|
Show UseLedgerAfter Source # | |
Defined in Ouroboros.Network.PeerSelection.LedgerPeers |
data PortNumber Source #
Port number.
Use the
Num
instance (i.e. use a literal) to create a
PortNumber
value.
>>>
1 :: PortNumber
1>>>
read "1" :: PortNumber
1>>>
show (12345 :: PortNumber)
"12345">>>
50000 < (51000 :: PortNumber)
True>>>
50000 < (52000 :: PortNumber)
True>>>
50000 + (10000 :: PortNumber)
60000