| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Network.Protocol.ObjectDiffusion.Examples
Synopsis
- testObjectDiffusionOutbound :: forall objectId object (m :: Type -> Type). (Ord objectId, Show objectId, Monad m, WithCaughtUpDetection objectId) => Tracer m (TraceObjectDiffusionTestImplem objectId object) -> (object -> objectId) -> Word16 -> [object] -> ObjectDiffusionOutbound objectId object m ()
- data TraceObjectDiffusionTestImplem objectId object
- = EventRecvMsgRequestObjectIds (StrictSeq objectId) (Map objectId object) [object] NumObjectIdsAck NumObjectIdsReq
- | EventRecvMsgRequestObjects (StrictSeq objectId) (Map objectId object) [object] [objectId]
- testObjectDiffusionInbound :: forall objectId object (m :: Type -> Type). (Ord objectId, WithCaughtUpDetection objectId) => Tracer m (TraceObjectDiffusionTestImplem objectId object) -> (object -> objectId) -> Word16 -> Word16 -> Word16 -> ObjectDiffusionInboundPipelined objectId object m [object]
- data InboundState objectId object = InboundState {
- requestedObjectIdsInFlight :: NumObjectIdsReq
- unacknowledgedObjectIds :: StrictSeq objectId
- availableObjectIds :: Set objectId
- bufferedObjects :: Map objectId (Maybe object)
- numObjectsToAcknowledge :: NumObjectIdsAck
- initialInboundState :: InboundState objectId object
- class Eq objectId => WithCaughtUpDetection objectId where
- caughtUpSentinel :: NonEmpty objectId
- ifCaughtUp :: forall object (m :: Type -> Type) a. InboundStIdle 'Z objectId object m a -> (NonEmpty objectId -> InboundStIdle 'Z objectId object m a) -> NonEmpty objectId -> InboundStIdle 'Z objectId object m a
Documentation
testObjectDiffusionOutbound Source #
Arguments
| :: forall objectId object (m :: Type -> Type). (Ord objectId, Show objectId, Monad m, WithCaughtUpDetection objectId) | |
| => Tracer m (TraceObjectDiffusionTestImplem objectId object) | |
| -> (object -> objectId) | |
| -> Word16 | Maximum number of unacknowledged object IDs allowed |
| -> [object] | |
| -> ObjectDiffusionOutbound objectId object m () |
data TraceObjectDiffusionTestImplem objectId object Source #
Constructors
| EventRecvMsgRequestObjectIds (StrictSeq objectId) (Map objectId object) [object] NumObjectIdsAck NumObjectIdsReq | |
| EventRecvMsgRequestObjects (StrictSeq objectId) (Map objectId object) [object] [objectId] |
Instances
| (Show objectId, Show object) => Show (TraceObjectDiffusionTestImplem objectId object) Source # | |
Defined in Ouroboros.Network.Protocol.ObjectDiffusion.Examples Methods showsPrec :: Int -> TraceObjectDiffusionTestImplem objectId object -> ShowS # show :: TraceObjectDiffusionTestImplem objectId object -> String # showList :: [TraceObjectDiffusionTestImplem objectId object] -> ShowS # | |
testObjectDiffusionInbound Source #
Arguments
| :: forall objectId object (m :: Type -> Type). (Ord objectId, WithCaughtUpDetection objectId) | |
| => Tracer m (TraceObjectDiffusionTestImplem objectId object) | |
| -> (object -> objectId) | |
| -> Word16 | Maximum number of unacknowledged object IDs allowed |
| -> Word16 | Maximum number of object IDs to request in any one go |
| -> Word16 | Maximum number of objects to request in any one go |
| -> ObjectDiffusionInboundPipelined objectId object m [object] |
data InboundState objectId object Source #
Constructors
| InboundState | |
Fields
| |
Instances
| (Show objectId, Show object) => Show (InboundState objectId object) Source # | |
Defined in Ouroboros.Network.Protocol.ObjectDiffusion.Examples Methods showsPrec :: Int -> InboundState objectId object -> ShowS # show :: InboundState objectId object -> String # showList :: [InboundState objectId object] -> ShowS # | |
initialInboundState :: InboundState objectId object Source #
class Eq objectId => WithCaughtUpDetection objectId where Source #
This helper typeclass allows the inbound and outbound tests implementation to finish the protocol gracefully when all the desired objects have been sent.
| Normally, the outbound side should always respond with a non-empty list of
object IDs to a blocking request, but instead it can respond with the
caughtUpSentinel (still inhabiting 'NonEmpty objectId') to indicate that
there are no more objects to send, and the inbound side can use ifCaughtUp
to detect this and terminate the protocol gracefully.
| This suggests that the concrete type used for objectId has some special
values that are not actually valid object IDs, but are used to signal this
condition. This is a bit hacky, but it allows us to keep the example
implementations simple and focused on the pipelining aspect, without having
to introduce additional protocol messages or state to handle termination.
Minimal complete definition
Methods
caughtUpSentinel :: NonEmpty objectId Source #
This is a special value that the outbound implementation can use to signal to the inbound implementation that there are no more objects to send. This ought to be a value that uses non-normal object IDs, but still inhabits 'NonEmpty objectId'.
ifCaughtUp :: forall object (m :: Type -> Type) a. InboundStIdle 'Z objectId object m a -> (NonEmpty objectId -> InboundStIdle 'Z objectId object m a) -> NonEmpty objectId -> InboundStIdle 'Z objectId object m a Source #
This is a helper function used in the inbound implementation to terminate the protocol gracefully when all objects that the outbound peer wanted to send have actually been sent.