ouroboros-network-protocols:testlib
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Protocol.ChainSync.Examples

Synopsis

Documentation

chainSyncClientExample :: forall header block tip (m :: Type -> Type) a. (HasHeader header, HasHeader block, HeaderHash header ~ HeaderHash block, MonadSTM m) => StrictTVar m (Chain header) -> Client header (Point block) tip m a -> ChainSyncClient header (Point block) tip m a Source #

An instance of the client side of the chain sync protocol that consumes into a Chain stored in a StrictTVar.

This is of course only useful in tests and reference implementations since this is not a realistic chain representation.

data Client header point tip (m :: Type -> Type) t Source #

Constructors

Client 

Fields

pureClient :: forall (m :: Type -> Type) header point tip void. Applicative m => Client header point tip m void Source #

A client which doesn't do anything and never ends. Used with chainSyncClientExample, the StrictTVar m (Chain header) will be updated but nothing further will happen.

controlledClient :: forall (m :: Type -> Type) header point tip. MonadSTM m => ControlMessageSTM m -> Client header point tip m () Source #

data Tip (b :: k) #

Used in chain-sync protocol to advertise the tip of the server's chain.

Constructors

TipGenesis

The tip is genesis

Tip !SlotNo !(HeaderHash b) !BlockNo

The tip is not genesis

Instances

Instances details
ShowProxy b => ShowProxy (Tip b :: Type) 
Instance details

Defined in Ouroboros.Network.Block

Methods

showProxy :: Proxy (Tip b) -> String #

Arbitrary (Tip BlockHeader) Source # 
Instance details

Defined in Ouroboros.Network.Protocol.ChainSync.Test

Generic (Tip b) 
Instance details

Defined in Ouroboros.Network.Block

Associated Types

type Rep (Tip b) 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Tip b) = D1 ('MetaData "Tip" "Ouroboros.Network.Block" "ouroboros-network-api-0.9.0.1-inplace" 'False) (C1 ('MetaCons "TipGenesis" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Tip" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HeaderHash b)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 BlockNo))))

Methods

from :: Tip b -> Rep (Tip b) x #

to :: Rep (Tip b) x -> Tip b #

StandardHash b => Show (Tip b) 
Instance details

Defined in Ouroboros.Network.Block

Methods

showsPrec :: Int -> Tip b -> ShowS #

show :: Tip b -> String #

showList :: [Tip b] -> ShowS #

StandardHash b => Eq (Tip b) 
Instance details

Defined in Ouroboros.Network.Block

Methods

(==) :: Tip b -> Tip b -> Bool #

(/=) :: Tip b -> Tip b -> Bool #

StandardHash b => NoThunks (Tip b) 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Tip b) 
Instance details

Defined in Ouroboros.Network.Block

type Rep (Tip b) = D1 ('MetaData "Tip" "Ouroboros.Network.Block" "ouroboros-network-api-0.9.0.1-inplace" 'False) (C1 ('MetaCons "TipGenesis" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Tip" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HeaderHash b)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 BlockNo))))

chainSyncServerExample :: forall blk header (m :: Type -> Type) a. (HasHeader blk, MonadSTM m, HeaderHash header ~ HeaderHash blk) => a -> StrictTVar m (ChainProducerState blk) -> (blk -> header) -> ChainSyncServer header (Point blk) (Tip blk) m a Source #

An instance of the server side of the chain sync protocol that reads from a pure ChainProducerState stored in a StrictTVar.

This is of course only useful in tests and reference implementations since this is not a realistic chain representation.