Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Network.TxSubmission.Inbound.V2.Decision
Contents
Synopsis
- data TxDecision txid tx = TxDecision {
- txdTxIdsToAcknowledge :: !NumTxIdsToAck
- txdTxIdsToRequest :: !NumTxIdsToReq
- txdPipelineTxIds :: !Bool
- txdTxsToRequest :: !(Map txid SizeInBytes)
- txdTxsToMempool :: !(TxsToMempool txid tx)
- emptyTxDecision :: TxDecision txid tx
- makeDecisions :: (Ord peeraddr, Ord txid, Hashable peeraddr) => TxDecisionPolicy -> SharedTxState peeraddr txid tx -> Map peeraddr (PeerTxState txid tx) -> (SharedTxState peeraddr txid tx, Map peeraddr (TxDecision txid tx))
- filterActivePeers :: forall peeraddr txid tx. (Ord txid, HasCallStack) => TxDecisionPolicy -> SharedTxState peeraddr txid tx -> Map peeraddr (PeerTxState txid tx)
- pickTxsToDownload :: (Ord peeraddr, Ord txid) => TxDecisionPolicy -> SharedTxState peeraddr txid tx -> [(peeraddr, PeerTxState txid tx)] -> (SharedTxState peeraddr txid tx, [(peeraddr, TxDecision txid tx)])
Documentation
data TxDecision txid tx Source #
Decision made by the decision logic. Each peer will receive a Decision
.
note: it is rather non-standard to represent a choice between requesting
txid
s and tx
's as a product rather than a sum type. The client will
need to download tx
s first and then send a request for more txids (and
acknowledge some txid
s). Due to pipelining each client will request
decision from the decision logic quite often (every two pipelined requests),
but with this design a decision once taken will make the peer non-active
(e.g. it won't be returned by filterActivePeers
) for longer, and thus the
expensive makeDecision
computation will not need to take that peer into
account.
Constructors
TxDecision | |
Fields
|
Instances
Ord txid => Semigroup (TxDecision txid tx) Source # | A non-commutative semigroup instance. note: this instance must be consistent with |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (<>) :: TxDecision txid tx -> TxDecision txid tx -> TxDecision txid tx # sconcat :: NonEmpty (TxDecision txid tx) -> TxDecision txid tx # stimes :: Integral b => b -> TxDecision txid tx -> TxDecision txid tx # | |
(Show txid, Show tx) => Show (TxDecision txid tx) Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TxDecision txid tx -> ShowS # show :: TxDecision txid tx -> String # showList :: [TxDecision txid tx] -> ShowS # | |
(Eq txid, Eq tx) => Eq (TxDecision txid tx) Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: TxDecision txid tx -> TxDecision txid tx -> Bool # (/=) :: TxDecision txid tx -> TxDecision txid tx -> Bool # |
emptyTxDecision :: TxDecision txid tx Source #
A no-op decision.
Internal API exposed for testing
Arguments
:: (Ord peeraddr, Ord txid, Hashable peeraddr) | |
=> TxDecisionPolicy | decision policy |
-> SharedTxState peeraddr txid tx | decision context |
-> Map peeraddr (PeerTxState txid tx) | list of available peers. This is a subset of |
-> (SharedTxState peeraddr txid tx, Map peeraddr (TxDecision txid tx)) |
Make download decisions.
filterActivePeers :: forall peeraddr txid tx. (Ord txid, HasCallStack) => TxDecisionPolicy -> SharedTxState peeraddr txid tx -> Map peeraddr (PeerTxState txid tx) Source #
Filter peers which can either download a tx
or acknowledge txid
s.
Arguments
:: (Ord peeraddr, Ord txid) | |
=> TxDecisionPolicy | decision policy |
-> SharedTxState peeraddr txid tx | shared state |
-> [(peeraddr, PeerTxState txid tx)] | |
-> (SharedTxState peeraddr txid tx, [(peeraddr, TxDecision txid tx)]) |
Distribute tx
's to download among available peers. Peers are considered
in the given order.
- pick txs from the set of available tx's (in
txid
order, note these sets might be different for different peers). - pick txs until the peers in-flight limit (we can go over the limit by one tx)
(
txsSizeInflightPerPeer
limit) - pick txs until the overall in-flight limit (we can go over the limit by one tx)
(
maxTxsSizeInflight
limit) - each tx can be downloaded simultaneously from at most
txInflightMultiplicity
peers.