| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Network.TxSubmission.Inbound.V2
Synopsis
- txSubmissionInboundV2 :: forall txid tx idx (m :: Type -> Type) err. (MonadDelay m, MonadSTM m, MonadThrow m, Ord txid, Show txid, Typeable txid) => Tracer m (TraceTxSubmissionInbound txid tx) -> TxSubmissionInitDelay -> TxDecisionPolicy -> TxSubmissionMempoolWriter txid tx idx m err -> (tx -> SizeInBytes) -> PeerTxAPI m txid tx -> TxSubmissionServerPipelined txid tx m ()
- module Ouroboros.Network.TxSubmission.Inbound.V2.Registry
- module Ouroboros.Network.TxSubmission.Inbound.V2.Types
- data TxDecisionPolicy = TxDecisionPolicy {
- maxNumTxIdsToRequest :: !NumTxIdsToReq
- maxUnacknowledgedTxIds :: !NumTxIdsToReq
- txsSizeInflightPerPeer :: !SizeInBytes
- maxOutstandingTxBatchesPerPeer :: !Int
- txInflightMultiplicity :: !Int
- bufferedTxsMinLifetime :: !DiffTime
- scoreRate :: !Double
- scoreMax :: !Double
- scoreAcceptDecrement :: !Double
- interTxSpace :: !DiffTime
- inflightTimeout :: !DiffTime
- maxPeerClaimDelay :: !DiffTime
- disablePipelinedTxIdRequests :: !Bool
- defaultTxDecisionPolicy :: TxDecisionPolicy
- data TxSubmissionInitDelay
TxSubmission Inbound client
txSubmissionInboundV2 :: forall txid tx idx (m :: Type -> Type) err. (MonadDelay m, MonadSTM m, MonadThrow m, Ord txid, Show txid, Typeable txid) => Tracer m (TraceTxSubmissionInbound txid tx) -> TxSubmissionInitDelay -> TxDecisionPolicy -> TxSubmissionMempoolWriter txid tx idx m err -> (tx -> SizeInBytes) -> PeerTxAPI m txid tx -> TxSubmissionServerPipelined txid tx m () Source #
A tx-submission inbound side (server, sic!).
Each call to runNextPeerAction atomically inspects the shared state and
this peer's local protocol state and returns one of: submit buffered
bodies to the mempool, request bodies, request txids (blocking or
pipelined), or do nothing. When idle, the server parks on
awaitSharedChange until the shared-state generation moves or an
optional wake delay expires, then re-evaluates. Body requests are
pipelined; in pipelined mode txid requests become non-blocking and the
server collects replies via handleReplies.
V2 server state machine.
Depth n tracks outstanding pipelined replies (type-level Nat).
States (non-pipelined, n = 0): serverIdle - park on awaitSharedChange or pick next action serverReqTxIds 0 - send a txid request (blocking or pipelined) submitBufferedTxs - submit buffered bodies, run continuation requestTxBodies - send a pipelined body request, depth + 1
States (pipelined, n > 0): continueAfterReplies - post-reply pick; dispatch action or DoNothing continueAfterBodyRequests - post-body-request pick; same dispatch handleReplies n - block on CollectPipelined for the next reply handleReply (n-1) - apply received txids or bodies, then continueAfterReplies (n-1)
Transitions:
serverIdle [PeerDoNothing] --> awaitSharedChange --> serverIdle [PeerSubmitTxs ks] --> submitBufferedTxs ks serverIdle [PeerRequestTxs ks] --> requestTxBodies 0 ks --> continueAfterBodyRequests 1 [PeerRequestTxIds] when unack queue empty --> blocking wire request, wait for reply --> serverIdle [PeerRequestTxIds] otherwise --> pipelined wire request --> handleReplies 1
handleReplies n --> handleReply (n-1) handleReply [CollectTxIds] --> applyReceivedTxIds --> continueAfterReplies (n-1) [CollectTxs] --> applyReceivedTxs --> continueAfterReplies (n-1)
continueAfterReplies 0 = serverIdle continueAfterReplies n@(>0), continueAfterBodyRequests n [PeerSubmitTxs ks] --> submitBufferedTxs ks (continueAfterReplies n) [PeerRequestTxs ks] --> requestTxBodies n ks [PeerRequestTxIds] --> serverReqTxIds n [PeerDoNothing] --> handleReplies n
Supporting types and APIs
data TxDecisionPolicy Source #
Policy for making decisions
Constructors
| TxDecisionPolicy | |
Fields
| |
Instances
| NFData TxDecisionPolicy Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Policy Methods rnf :: TxDecisionPolicy -> () # | |
| Show TxDecisionPolicy Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Policy Methods showsPrec :: Int -> TxDecisionPolicy -> ShowS # show :: TxDecisionPolicy -> String # showList :: [TxDecisionPolicy] -> ShowS # | |
| Eq TxDecisionPolicy Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Policy Methods (==) :: TxDecisionPolicy -> TxDecisionPolicy -> Bool # (/=) :: TxDecisionPolicy -> TxDecisionPolicy -> Bool # | |
data TxSubmissionInitDelay Source #
Constructors
| TxSubmissionInitDelay DiffTime | |
| NoTxSubmissionInitDelay |
Instances
| Show TxSubmissionInitDelay Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TxSubmissionInitDelay -> ShowS # show :: TxSubmissionInitDelay -> String # showList :: [TxSubmissionInitDelay] -> ShowS # | |
| Eq TxSubmissionInitDelay Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: TxSubmissionInitDelay -> TxSubmissionInitDelay -> Bool # (/=) :: TxSubmissionInitDelay -> TxSubmissionInitDelay -> Bool # | |