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

Test.Ouroboros.Network.Testnet.Node.ChainDB

Synopsis

Documentation

data ChainDB block (m :: Type -> Type) Source #

ChainDB is an in memory store of all fetched (downloaded) blocks.

This type holds an index mapping previous hashes to their blocks (i.e. if a block A has prevHash H then the entry "H -> [A]" exists in the map) and the current version of the longest chain.

Used to simulate real world ChainDB, it offers the invariant that cdbLongestChainVar is always the longest known chain of downloaded blocks. Whenever a node generates a new block it gets added here, and whenever it gets a block via block fetch it gets added here as well. Everytime addBlock is called the possibly new longest chain gets computed, since the API is atomic we can guarantee that in each moment ChainDB has the current longest chain.

This type is used in diffusion simulation.

Constructors

ChainDB 

Fields

newtype SelectChain block Source #

Chain selection as a Monoid.

Constructors

SelectChain 

Fields

Instances

Instances details
HasHeader block => Monoid (SelectChain block) Source # 
Instance details

Defined in Test.Ouroboros.Network.Testnet.Node.ChainDB

Methods

mempty :: SelectChain block #

mappend :: SelectChain block -> SelectChain block -> SelectChain block #

mconcat :: [SelectChain block] -> SelectChain block #

HasHeader block => Semigroup (SelectChain block) Source # 
Instance details

Defined in Test.Ouroboros.Network.Testnet.Node.ChainDB

Methods

(<>) :: SelectChain block -> SelectChain block -> SelectChain block #

sconcat :: NonEmpty (SelectChain block) -> SelectChain block #

stimes :: Integral b => b -> SelectChain block -> SelectChain block #

newChainDB :: MonadSTM m => m (ChainDB block m) Source #

Constructs a new ChainDB, the index has only 1 value which is the GenesisHash but this hash does not map to any block.

addBlock :: forall (m :: Type -> Type) block. (MonadSTM m, HasFullHeader block) => block -> ChainDB block m -> STM m () Source #

Adds a block to ChainDB.

This function also recomputes the longest chain with the new block information.

getBlockPointSet :: forall (m :: Type -> Type) block. (MonadSTM m, HasHeader block) => ChainDB block m -> STM m (Set (Point block)) Source #

Constructs the block Point set of all downloaded blocks