ouroboros-network:protocols-tests-lib
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Protocol.ObjectDiffusion.Examples

Synopsis

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

Instances details
(Show objectId, Show object) => Show (TraceObjectDiffusionTestImplem objectId object) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.ObjectDiffusion.Examples

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

Instances details
(Show objectId, Show object) => Show (InboundState objectId object) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.ObjectDiffusion.Examples

Methods

showsPrec :: Int -> InboundState objectId object -> ShowS #

show :: InboundState objectId object -> String #

showList :: [InboundState objectId object] -> ShowS #

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

caughtUpSentinel

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.

Instances

Instances details
WithCaughtUpDetection ObjectId Source # 
Instance details

Defined in Ouroboros.Network.Protocol.ObjectDiffusion.Test

Methods

caughtUpSentinel :: NonEmpty ObjectId Source #

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 #