ouroboros-network
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.TxSubmission.Inbound.V2.Decision

Synopsis

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 txids and tx's as a product rather than a sum type. The client will need to download txs first and then send a request for more txids (and acknowledge some txids). 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

Instances details
Ord txid => Semigroup (TxDecision txid tx) Source #

A non-commutative semigroup instance.

note: this instance must be consistent with pickTxsToDownload and how PeerTxState is updated. It is designed to work with TMergeVars.

Instance details

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 # 
Instance details

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 # 
Instance details

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

makeDecisions Source #

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 peerTxStates of peers which either: * can be used to download a tx, * can acknowledge some txids.

-> (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 txids.

pickTxsToDownload Source #

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.