| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Network.TxSubmission.Inbound.V2.Types
Synopsis
- data SharedTxState peeraddr txid = SharedTxState {
- sharedTxTable :: !(IntMap (TxEntry peeraddr))
- sharedRetainedTxs :: !RetainedTxs
- sharedTxIdToKey :: !(Map (RawTxId txid) TxKey)
- sharedKeyToTxId :: !(IntMap txid)
- sharedNextTxKey :: !Int
- sharedGeneration :: !Word64
- sharedRevision :: !Word64
- data RetainedTxs
- retainedEmpty :: RetainedTxs
- retainedSingleton :: Int -> Time -> RetainedTxs
- retainedFromList :: [(Int, Time)] -> RetainedTxs
- retainedToList :: RetainedTxs -> [(Int, Time)]
- retainedSize :: RetainedTxs -> Int
- retainedLookup :: Int -> RetainedTxs -> Maybe Time
- retainedMember :: Int -> RetainedTxs -> Bool
- retainedInsertMax :: Int -> Time -> RetainedTxs -> RetainedTxs
- retainedDeleteKeys :: IntSet -> RetainedTxs -> RetainedTxs
- retainedKeysSet :: RetainedTxs -> IntSet
- retainedRestrictKeys :: RetainedTxs -> IntSet -> RetainedTxs
- retainedExpiredKeys :: Time -> RetainedTxs -> IntSet
- data TraceTxLogic peeraddr txid tx = TraceSharedTxState (SharedTxState peeraddr txid)
- data TxSubmissionInitDelay
- defaultTxSubmissionInitDelay :: TxSubmissionInitDelay
- const_MAX_TX_SIZE_DISCREPANCY :: SizeInBytes
- data ProcessedTxCount = ProcessedTxCount {
- ptxcAccepted :: Int
- ptxcRejected :: Int
- ptxcScore :: Double
- data TxSubmissionLogicVersion
- data TxSubmissionMempoolWriter txid tx idx (m :: Type -> Type) err = TxSubmissionMempoolWriter {
- txId :: tx -> txid
- mempoolAddTxs :: [tx] -> m ([txid], [(txid, err)])
- data TraceTxSubmissionInbound txid tx
- = TraceTxSubmissionCollected [txid]
- | TraceTxSubmissionProcessed ProcessedTxCount
- | TraceTxInboundCanRequestMoreTxs Int
- | TraceTxInboundCannotRequestMoreTxs Int
- | TraceTxInboundAddedToMempool [txid] DiffTime
- | TraceTxInboundRejectedFromMempool [txid] DiffTime
- | TraceTxInboundError TxSubmissionProtocolError
- | TraceTxInboundRequestTxs [txid]
- | TraceTxInboundTerminated
- data TxSubmissionCounters = TxSubmissionCounters {
- txIdMessagesSent :: !Word64
- txIdsRequested :: !Word64
- txIdRepliesReceived :: !Word64
- txIdsReceived :: !Word64
- txMessagesSent :: !Word64
- txsRequested :: !Word64
- txRepliesReceived :: !Word64
- txsReceived :: !Word64
- txsOmitted :: !Word64
- lateBodies :: !Word64
- txsAccepted :: !Word64
- txsRejected :: !Word64
- txIdBlockingReqsSent :: !Word64
- txIdPipelinedReqsSent :: !Word64
- txIdBlockingWaitMs :: !Word64
- txPipelineWaitMs :: !Word64
- txSubmissionWaitMs :: !Word64
- data TxSubmissionProtocolError
- = ProtocolErrorTxNotRequested
- | ProtocolErrorTxIdsNotRequested
- | (Typeable txid, Show txid, Eq txid) => ProtocolErrorTxSizeError [(txid, SizeInBytes, SizeInBytes)]
- data RequestedTxBatch = RequestedTxBatch {}
- data TxLease peeraddr
- = TxLeased !peeraddr !Time
- | TxClaimable !Time
- data TxEntry peeraddr = TxEntry {
- txLease :: !(TxLease peeraddr)
- txAttempt :: !Int
- txInSubmission :: !Bool
- currentMaxInflightMultiplicity :: !Int
- data PeerAction
- = PeerDoNothing !Word64 !(Maybe DiffTime)
- | PeerRequestTxIds !NumTxIdsToAck !NumTxIdsToReq
- | PeerRequestTxs ![TxKey]
- | PeerSubmitTxs ![TxKey]
- data PeerPhase
- data PeerScore = PeerScore {
- peerScoreValue :: !Double
- peerScoreTs :: !Time
- data PeerTxLocalState tx = PeerTxLocalState {
- peerPhase :: !PeerPhase
- peerUnacknowledgedTxIds :: !(StrictSeq TxKey)
- peerAvailableTxIds :: !(IntMap SizeInBytes)
- peerRequestedTxs :: !IntSet
- peerRequestedTxBatches :: !(StrictSeq RequestedTxBatch)
- peerRequestedTxsSize :: !SizeInBytes
- peerRequestedTxIds :: !NumTxIdsToReq
- peerDownloadedTxs :: !(IntMap tx)
- peerDownloadStartTime :: !(Maybe Time)
- peerScore :: !PeerScore
- peerLastTxIdReplyWasEmpty :: !Bool
- data PeerTxInFlight = PeerTxInFlight {
- pifAdvertised :: !IntSet
- pifLeased :: !IntSet
- pifAttempting :: !IntSet
- pifSubmitting :: !IntSet
- pifAcksPending :: !IntSet
- emptyPeerTxInFlight :: PeerTxInFlight
- newtype TxKey = TxKey {}
- lookupTxKey :: HasRawTxId txid => txid -> SharedTxState peeraddr txid -> Maybe TxKey
- resolveTxKey :: HasCallStack => SharedTxState peeraddr txid -> TxKey -> txid
- internTxId :: HasRawTxId txid => txid -> SharedTxState peeraddr txid -> (RawTxId txid, TxKey, SharedTxState peeraddr txid)
- internTxIds :: (Foldable f, HasRawTxId txid) => f txid -> SharedTxState peeraddr txid -> (Map (RawTxId txid) TxKey, SharedTxState peeraddr txid)
- emptyPeerScore :: Time -> PeerScore
- emptyPeerTxLocalState :: PeerTxLocalState tx
- emptySharedTxState :: SharedTxState peeraddr txid
- diffTimeToMilliseconds :: DiffTime -> Word64
Shared state
data SharedTxState peeraddr txid Source #
Shared V2 state.
There is no global decision thread. Peer worker threads coordinate by atomically reading and updating this shared state.
Invariants (see sharedTxStateInvariant):
- the active (
sharedTxTable) and retained (sharedRetainedTxs) key sets are disjoint. sharedTxIdToKeyandsharedKeyToTxIdare mutual inverses (equal size, round-tripping in both directions).- every live key (active union retained) is present in those two maps.
sharedNextTxKeyis strictly greater than every live key, so a freshly interned key never collides with a live one.
Cross-step (see sharedGenerationBumpInvariant): both counters are
monotone non-decreasing, and any transition that changes some other
field must advance sharedGeneration or sharedRevision;
writeSharedStateIfChanged silently drops a commit that bumps neither.
Constructors
| SharedTxState | |
Fields
| |
Instances
RetainedTxs with helper functions
data RetainedTxs Source #
Keys of transactions tx-submission knows are in the mempool, kept for a a limited time.
A key enters whenever we learns that the tx is in the mempool:
- a body we submitted is accepted, or
- a peer announces a txid, or delivers a body, that the mempool already holds. Could be due to earlier fetches, or the TX may have arrived through the LocalTxSubmission protocol.
In each case the key is dropped from the active sharedTxTable and
inserted here with deadline now + bufferedTxsMinLifetime (re-insert
keeps the later deadline). A key leaves only when that deadline passes
and the shared-state sweep removes it, independent of whether peers
have acked it yet.
While retained a key counts as resolved: its txid may be acked to the
announcing peers, and a re-announced txid or late-arriving body is
treated as already handled rather than re-fetched. A rejected tx is
not retained, it stays claimable in sharedTxTable so peers retry it.
Backed by two indexes:
retainedQueueis keyed onTimefor cheap earliest-expiry queries.retainedSetshadows the keys for O(min(n, W))retainedMemberqueries (the hot path: every received txid is checked here).
Both are kept in lockstep by the 'retained*' helpers below.
Instances
retainedSingleton :: Int -> Time -> RetainedTxs Source #
retainedFromList :: [(Int, Time)] -> RetainedTxs Source #
retainedToList :: RetainedTxs -> [(Int, Time)] Source #
retainedSize :: RetainedTxs -> Int Source #
retainedLookup :: Int -> RetainedTxs -> Maybe Time Source #
retainedMember :: Int -> RetainedTxs -> Bool Source #
retainedInsertMax :: Int -> Time -> RetainedTxs -> RetainedTxs Source #
retainedDeleteKeys :: IntSet -> RetainedTxs -> RetainedTxs Source #
retainedKeysSet :: RetainedTxs -> IntSet Source #
retainedRestrictKeys :: RetainedTxs -> IntSet -> RetainedTxs Source #
retainedExpiredKeys :: Time -> RetainedTxs -> IntSet Source #
Traces
data TraceTxLogic peeraddr txid tx Source #
TxLogic tracer.
Constructors
| TraceSharedTxState (SharedTxState peeraddr txid) |
Instances
| (HasRawTxId txid, Show peeraddr, Show txid) => Show (TraceTxLogic peeraddr txid tx) Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TraceTxLogic peeraddr txid tx -> ShowS # show :: TraceTxLogic peeraddr txid tx -> String # showList :: [TraceTxLogic peeraddr txid tx] -> ShowS # | |
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 # | |
const_MAX_TX_SIZE_DISCREPANCY :: SizeInBytes Source #
We check advertised sizes in a fuzzy way. The advertised and received sizes need to agree up to this discrepancy.
Types shared with V1
Various
data ProcessedTxCount Source #
Constructors
| ProcessedTxCount | |
Fields
| |
Instances
| Show ProcessedTxCount Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> ProcessedTxCount -> ShowS # show :: ProcessedTxCount -> String # showList :: [ProcessedTxCount] -> ShowS # | |
| Eq ProcessedTxCount Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: ProcessedTxCount -> ProcessedTxCount -> Bool # (/=) :: ProcessedTxCount -> ProcessedTxCount -> Bool # | |
data TxSubmissionLogicVersion Source #
Flag to enable/disable the usage of the new tx-submission logic.
Constructors
| TxSubmissionLogicV1 | the legacy |
| TxSubmissionLogicV2 | the new |
Instances
| Bounded TxSubmissionLogicVersion Source # | |
| Enum TxSubmissionLogicVersion Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods succ :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion # pred :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion # toEnum :: Int -> TxSubmissionLogicVersion # fromEnum :: TxSubmissionLogicVersion -> Int # enumFrom :: TxSubmissionLogicVersion -> [TxSubmissionLogicVersion] # enumFromThen :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion -> [TxSubmissionLogicVersion] # enumFromTo :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion -> [TxSubmissionLogicVersion] # enumFromThenTo :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion -> TxSubmissionLogicVersion -> [TxSubmissionLogicVersion] # | |
| Show TxSubmissionLogicVersion Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TxSubmissionLogicVersion -> ShowS # show :: TxSubmissionLogicVersion -> String # showList :: [TxSubmissionLogicVersion] -> ShowS # | |
| Eq TxSubmissionLogicVersion Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion -> Bool # (/=) :: TxSubmissionLogicVersion -> TxSubmissionLogicVersion -> Bool # | |
Mempool API
data TxSubmissionMempoolWriter txid tx idx (m :: Type -> Type) err Source #
The consensus layer functionality that the inbound side of the tx submission logic requires.
This is provided to the tx submission logic by the consensus layer.
Constructors
| TxSubmissionMempoolWriter | |
Fields
| |
Traces
data TraceTxSubmissionInbound txid tx Source #
Constructors
| TraceTxSubmissionCollected [txid] | Number of transactions just about to be inserted. |
| TraceTxSubmissionProcessed ProcessedTxCount | Just processed transaction pass/fail breakdown. |
| TraceTxInboundCanRequestMoreTxs Int | |
| TraceTxInboundCannotRequestMoreTxs Int | |
| TraceTxInboundAddedToMempool [txid] DiffTime | |
| TraceTxInboundRejectedFromMempool [txid] DiffTime | |
| TraceTxInboundError TxSubmissionProtocolError | |
| TraceTxInboundRequestTxs [txid] | |
| TraceTxInboundTerminated | Server received |
Instances
| Show txid => Show (TraceTxSubmissionInbound txid tx) Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TraceTxSubmissionInbound txid tx -> ShowS # show :: TraceTxSubmissionInbound txid tx -> String # showList :: [TraceTxSubmissionInbound txid tx] -> ShowS # | |
| Eq txid => Eq (TraceTxSubmissionInbound txid tx) Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: TraceTxSubmissionInbound txid tx -> TraceTxSubmissionInbound txid tx -> Bool # (/=) :: TraceTxSubmissionInbound txid tx -> TraceTxSubmissionInbound txid tx -> Bool # | |
data TxSubmissionCounters Source #
Low-cost monotonic counters for the V2 peer protocol and coordination path.
These counters are updated incrementally at the points where V2 performs
protocol sends, receives replies, or cheaply classifies received bodies.
They are kept separate from SharedTxState so that emission can read a
small dedicated counter cell without scanning protocol state.
Constructors
| TxSubmissionCounters | |
Fields
| |
Instances
| NFData TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods rnf :: TxSubmissionCounters -> () # | |||||
| Monoid TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods mempty :: TxSubmissionCounters # mappend :: TxSubmissionCounters -> TxSubmissionCounters -> TxSubmissionCounters # | |||||
| Semigroup TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (<>) :: TxSubmissionCounters -> TxSubmissionCounters -> TxSubmissionCounters # sconcat :: NonEmpty TxSubmissionCounters -> TxSubmissionCounters # stimes :: Integral b => b -> TxSubmissionCounters -> TxSubmissionCounters # | |||||
| Generic TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
Methods from :: TxSubmissionCounters -> Rep TxSubmissionCounters x # to :: Rep TxSubmissionCounters x -> TxSubmissionCounters # | |||||
| Show TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TxSubmissionCounters -> ShowS # show :: TxSubmissionCounters -> String # showList :: [TxSubmissionCounters] -> ShowS # | |||||
| Eq TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: TxSubmissionCounters -> TxSubmissionCounters -> Bool # (/=) :: TxSubmissionCounters -> TxSubmissionCounters -> Bool # | |||||
| type Rep TxSubmissionCounters Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep TxSubmissionCounters = D1 ('MetaData "TxSubmissionCounters" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "TxSubmissionCounters" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "txIdMessagesSent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txIdsRequested") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "txIdRepliesReceived") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txIdsReceived") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "txMessagesSent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txsRequested") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "txRepliesReceived") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txsReceived") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)))) :*: (((S1 ('MetaSel ('Just "txsOmitted") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "lateBodies") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "txsAccepted") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txsRejected") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "txIdBlockingReqsSent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txIdPipelinedReqsSent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "txIdBlockingWaitMs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: (S1 ('MetaSel ('Just "txPipelineWaitMs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "txSubmissionWaitMs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))))))) | |||||
Protocol Error
data TxSubmissionProtocolError Source #
Constructors
| ProtocolErrorTxNotRequested | |
| ProtocolErrorTxIdsNotRequested | |
| (Typeable txid, Show txid, Eq txid) => ProtocolErrorTxSizeError [(txid, SizeInBytes, SizeInBytes)] | a list of txid for which the received size and advertised size didn't match. |
Instances
| Exception TxSubmissionProtocolError Source # | |
| Show TxSubmissionProtocolError Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> TxSubmissionProtocolError -> ShowS # show :: TxSubmissionProtocolError -> String # showList :: [TxSubmissionProtocolError] -> ShowS # | |
| Eq TxSubmissionProtocolError Source # | |
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: TxSubmissionProtocolError -> TxSubmissionProtocolError -> Bool # (/=) :: TxSubmissionProtocolError -> TxSubmissionProtocolError -> Bool # | |
data RequestedTxBatch Source #
A batch of transaction body requests sent to a peer.
Tracks the set of requested txids and the total expected size in bytes for the batch. Used to manage inflight requests and match responses to the original request.
Constructors
| RequestedTxBatch | |
Fields
| |
Instances
| NFData RequestedTxBatch Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods rnf :: RequestedTxBatch -> () # | |||||
| Generic RequestedTxBatch Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
Methods from :: RequestedTxBatch -> Rep RequestedTxBatch x # to :: Rep RequestedTxBatch x -> RequestedTxBatch # | |||||
| Show RequestedTxBatch Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> RequestedTxBatch -> ShowS # show :: RequestedTxBatch -> String # showList :: [RequestedTxBatch] -> ShowS # | |||||
| Eq RequestedTxBatch Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: RequestedTxBatch -> RequestedTxBatch -> Bool # (/=) :: RequestedTxBatch -> RequestedTxBatch -> Bool # | |||||
| NoThunks RequestedTxBatch Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods noThunks :: Context -> RequestedTxBatch -> IO (Maybe ThunkInfo) # wNoThunks :: Context -> RequestedTxBatch -> IO (Maybe ThunkInfo) # showTypeOf :: Proxy RequestedTxBatch -> String # | |||||
| type Rep RequestedTxBatch Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep RequestedTxBatch = D1 ('MetaData "RequestedTxBatch" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "RequestedTxBatch" 'PrefixI 'True) (S1 ('MetaSel ('Just "requestedTxBatchSet") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet) :*: S1 ('MetaSel ('Just "requestedTxBatchSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SizeInBytes))) | |||||
data TxLease peeraddr Source #
The current download lease for a tx body.
A tx is either currently leased to a peer until a deadline or it is unowned and became claimable at a specific time. Peers use their decayed score as an additional per-peer delay after that claimable time before attempting to steal the lease.
Constructors
| TxLeased !peeraddr !Time | |
| TxClaimable !Time |
Instances
| NFData peeraddr => NFData (TxLease peeraddr) Source # | |||||
| Generic (TxLease peeraddr) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
| |||||
| Show peeraddr => Show (TxLease peeraddr) Source # | |||||
| Eq peeraddr => Eq (TxLease peeraddr) Source # | |||||
| NoThunks peeraddr => NoThunks (TxLease peeraddr) Source # | |||||
| type Rep (TxLease peeraddr) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep (TxLease peeraddr) = D1 ('MetaData "TxLease" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "TxLeased" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 peeraddr) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Time)) :+: C1 ('MetaCons "TxClaimable" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Time))) | |||||
data TxEntry peeraddr Source #
Shared per-tx state.
V2 keeps all cross-peer coordination at tx granularity. The first peer that advertises a new txid becomes its initial owner. If the lease expires without a successful outcome, the tx becomes claimable and another eligible advertiser may atomically claim it.
Per-peer attempt detail is tracked in each peer's PeerTxInFlight
TVar (owned by withPeer). The shared entry only carries
aggregate counts: how many peers are currently attempting this body
and whether any peer is mid mempool submission.
Constructors
| TxEntry | |
Fields
| |
Instances
| NFData peeraddr => NFData (TxEntry peeraddr) Source # | |||||
| Generic (TxEntry peeraddr) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
| |||||
| Show peeraddr => Show (TxEntry peeraddr) Source # | |||||
| Eq peeraddr => Eq (TxEntry peeraddr) Source # | |||||
| NoThunks peeraddr => NoThunks (TxEntry peeraddr) Source # | |||||
| type Rep (TxEntry peeraddr) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep (TxEntry peeraddr) = D1 ('MetaData "TxEntry" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "TxEntry" 'PrefixI 'True) ((S1 ('MetaSel ('Just "txLease") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (TxLease peeraddr)) :*: S1 ('MetaSel ('Just "txAttempt") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "txInSubmission") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "currentMaxInflightMultiplicity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)))) | |||||
data PeerAction Source #
The next peer-local action chosen by the V2 worker thread.
V2 drives progress from the peer thread itself. Shared state only decides whether a peer is allowed to perform an action; the peer thread then carries it out directly.
Constructors
| PeerDoNothing !Word64 !(Maybe DiffTime) | No immediate work is available. The peer should wait for either a shared-state generation change or the optional timeout. |
| PeerRequestTxIds !NumTxIdsToAck !NumTxIdsToReq | Send a txid protocol message acknowledging the first argument and requesting the second argument. |
| PeerRequestTxs ![TxKey] | Request tx bodies for the given internally keyed txs from this peer. |
| PeerSubmitTxs ![TxKey] | Submit the buffered txs identified by the given keys to the local mempool. |
Instances
| NFData PeerAction Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods rnf :: PeerAction -> () # | |||||
| Generic PeerAction Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
| |||||
| Show PeerAction Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> PeerAction -> ShowS # show :: PeerAction -> String # showList :: [PeerAction] -> ShowS # | |||||
| Eq PeerAction Source # | |||||
| type Rep PeerAction Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep PeerAction = D1 ('MetaData "PeerAction" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) ((C1 ('MetaCons "PeerDoNothing" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe DiffTime))) :+: C1 ('MetaCons "PeerRequestTxIds" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NumTxIdsToAck) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NumTxIdsToReq))) :+: (C1 ('MetaCons "PeerRequestTxs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TxKey])) :+: C1 ('MetaCons "PeerSubmitTxs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TxKey])))) | |||||
Coarse phase of a peer worker thread.
The phase is used when deciding whether a peer is currently eligible to claim an expired tx lease.
Constructors
| PeerIdle | The peer worker is idle and may claim work for advertised txs. |
| PeerWaitingTxIds | The peer worker is waiting for a txid reply from the remote peer. |
| PeerWaitingTxs | The peer worker is waiting for a tx-body reply from the remote peer. |
| PeerSubmittingToMempool | The peer worker is submitting buffered txs to the local mempool. |
Instances
| NFData PeerPhase Source # | |||||
| Generic PeerPhase Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
| |||||
| Show PeerPhase Source # | |||||
| Eq PeerPhase Source # | |||||
| Ord PeerPhase Source # | |||||
| NoThunks PeerPhase Source # | |||||
| type Rep PeerPhase Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep PeerPhase = D1 ('MetaData "PeerPhase" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) ((C1 ('MetaCons "PeerIdle" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PeerWaitingTxIds" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PeerWaitingTxs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PeerSubmittingToMempool" 'PrefixI 'False) (U1 :: Type -> Type))) | |||||
Peer usefulness score.
Lower is better. The current score is also interpreted as milliseconds of extra delay before an idle peer may steal a claimable or expired tx lease.
Constructors
| PeerScore | |
Fields
| |
Instances
| NFData PeerScore Source # | |||||
| Generic PeerScore Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
| |||||
| Show PeerScore Source # | |||||
| Eq PeerScore Source # | |||||
| NoThunks PeerScore Source # | |||||
| type Rep PeerScore Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep PeerScore = D1 ('MetaData "PeerScore" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "PeerScore" 'PrefixI 'True) (S1 ('MetaSel ('Just "peerScoreValue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double) :*: S1 ('MetaSel ('Just "peerScoreTs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Time))) | |||||
data PeerTxLocalState tx Source #
Per-peer protocol state.
Owned by the worker thread for one peer. Includes the peer's coarse
protocol phase (peerPhase), which is purely peer-local: only this
peer's own scheduler reads and updates it, so it doesn't belong in
shared state.
Invariants (see peerTxLocalStateInvariant):
peerRequestedTxsis a subset of thepeerAvailableTxIdskeys, which are a subset of thepeerUnacknowledgedTxIdskeys.peerDownloadedTxskeys are a subset of the unacknowledged queue and disjoint from bothpeerAvailableTxIdsandpeerRequestedTxs: a key leaves available/requested exactly when its body lands in downloaded.peerRequestedTxsequals the union of every batch'srequestedTxBatchSet, andpeerRequestedTxsSizethe sum of theirrequestedTxBatchSize.- the
peerScorevalue stays in[0, scoreMax].
Constructors
| PeerTxLocalState | |
Fields
| |
Instances
| NFData tx => NFData (PeerTxLocalState tx) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods rnf :: PeerTxLocalState tx -> () # | |||||
| Generic (PeerTxLocalState tx) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
Methods from :: PeerTxLocalState tx -> Rep (PeerTxLocalState tx) x # to :: Rep (PeerTxLocalState tx) x -> PeerTxLocalState tx # | |||||
| Show tx => Show (PeerTxLocalState tx) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> PeerTxLocalState tx -> ShowS # show :: PeerTxLocalState tx -> String # showList :: [PeerTxLocalState tx] -> ShowS # | |||||
| Eq tx => Eq (PeerTxLocalState tx) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: PeerTxLocalState tx -> PeerTxLocalState tx -> Bool # (/=) :: PeerTxLocalState tx -> PeerTxLocalState tx -> Bool # | |||||
| NoThunks tx => NoThunks (PeerTxLocalState tx) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods noThunks :: Context -> PeerTxLocalState tx -> IO (Maybe ThunkInfo) # wNoThunks :: Context -> PeerTxLocalState tx -> IO (Maybe ThunkInfo) # showTypeOf :: Proxy (PeerTxLocalState tx) -> String # | |||||
| type Rep (PeerTxLocalState tx) Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep (PeerTxLocalState tx) = D1 ('MetaData "PeerTxLocalState" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "PeerTxLocalState" 'PrefixI 'True) (((S1 ('MetaSel ('Just "peerPhase") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PeerPhase) :*: S1 ('MetaSel ('Just "peerUnacknowledgedTxIds") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictSeq TxKey))) :*: (S1 ('MetaSel ('Just "peerAvailableTxIds") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (IntMap SizeInBytes)) :*: (S1 ('MetaSel ('Just "peerRequestedTxs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet) :*: S1 ('MetaSel ('Just "peerRequestedTxBatches") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictSeq RequestedTxBatch))))) :*: ((S1 ('MetaSel ('Just "peerRequestedTxsSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SizeInBytes) :*: (S1 ('MetaSel ('Just "peerRequestedTxIds") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NumTxIdsToReq) :*: S1 ('MetaSel ('Just "peerDownloadedTxs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (IntMap tx)))) :*: (S1 ('MetaSel ('Just "peerDownloadStartTime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Time)) :*: (S1 ('MetaSel ('Just "peerScore") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PeerScore) :*: S1 ('MetaSel ('Just "peerLastTxIdReplyWasEmpty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))) | |||||
data PeerTxInFlight Source #
Per-peer in-flight tracking, owned by withPeer.
The peer thread updates this TVar in the same STM transaction as
the shared TxEntry so the two stay coherent. Two readers:
- On exception,
withPeers bracket finalizer reads it and reverses each per-peer contribution: releases any held lease, decrementstxAttemptfor each attempted key, clearstxInSubmissionfor any in-flight submission. - The sweep walks every live peer's TVar to compute the union of advertised keys and skips those entries when looking for orphans to retire (the entry is still wanted by an active peer that may simply be slow to claim).
Invariant: pifAttempting and pifSubmitting are disjoint; a key
moves from the former to the latter atomically on the submit
transition. pifLeased is a subset of their union.
Constructors
| PeerTxInFlight | |
Fields
| |
Instances
| NFData PeerTxInFlight Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods rnf :: PeerTxInFlight -> () # | |||||
| Generic PeerTxInFlight Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Associated Types
Methods from :: PeerTxInFlight -> Rep PeerTxInFlight x # to :: Rep PeerTxInFlight x -> PeerTxInFlight # | |||||
| Show PeerTxInFlight Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods showsPrec :: Int -> PeerTxInFlight -> ShowS # show :: PeerTxInFlight -> String # showList :: [PeerTxInFlight] -> ShowS # | |||||
| Eq PeerTxInFlight Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods (==) :: PeerTxInFlight -> PeerTxInFlight -> Bool # (/=) :: PeerTxInFlight -> PeerTxInFlight -> Bool # | |||||
| NoThunks PeerTxInFlight Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types Methods noThunks :: Context -> PeerTxInFlight -> IO (Maybe ThunkInfo) # wNoThunks :: Context -> PeerTxInFlight -> IO (Maybe ThunkInfo) # showTypeOf :: Proxy PeerTxInFlight -> String # | |||||
| type Rep PeerTxInFlight Source # | |||||
Defined in Ouroboros.Network.TxSubmission.Inbound.V2.Types type Rep PeerTxInFlight = D1 ('MetaData "PeerTxInFlight" "Ouroboros.Network.TxSubmission.Inbound.V2.Types" "ouroboros-network-1.1.0.0-inplace" 'False) (C1 ('MetaCons "PeerTxInFlight" 'PrefixI 'True) ((S1 ('MetaSel ('Just "pifAdvertised") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet) :*: S1 ('MetaSel ('Just "pifLeased") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet)) :*: (S1 ('MetaSel ('Just "pifAttempting") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet) :*: (S1 ('MetaSel ('Just "pifSubmitting") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet) :*: S1 ('MetaSel ('Just "pifAcksPending") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IntSet))))) | |||||
Compact internal transaction key used by V2 state.
lookupTxKey :: HasRawTxId txid => txid -> SharedTxState peeraddr txid -> Maybe TxKey Source #
resolveTxKey :: HasCallStack => SharedTxState peeraddr txid -> TxKey -> txid Source #
internTxId :: HasRawTxId txid => txid -> SharedTxState peeraddr txid -> (RawTxId txid, TxKey, SharedTxState peeraddr txid) Source #
Intern a txid into the shared lookup tables. Returns the txid's
raw form, its stable TxKey (existing if already interned, freshly
allocated otherwise), and the resulting shared state.
internTxIds :: (Foldable f, HasRawTxId txid) => f txid -> SharedTxState peeraddr txid -> (Map (RawTxId txid) TxKey, SharedTxState peeraddr txid) Source #
emptyPeerScore :: Time -> PeerScore Source #
emptySharedTxState :: SharedTxState peeraddr txid Source #
diffTimeToMilliseconds :: DiffTime -> Word64 Source #
Convert a non-negative DiffTime to whole milliseconds (truncated).
Works directly on the underlying picosecond Integer to avoid the
realToFrac detour through Rational and Double.