Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ChainDB block (m :: Type -> Type) = ChainDB {
- cdbIndexVar :: TVar m (Map (ChainHash block) [block])
- cdbLongestChainVar :: TVar m (Chain block)
- newtype SelectChain block = SelectChain {
- getSelectedChain :: Chain block
- newChainDB :: MonadSTM m => m (ChainDB block m)
- addBlock :: forall (m :: Type -> Type) block. (MonadSTM m, HasFullHeader block) => block -> ChainDB block m -> STM m ()
- getBlockPointSet :: forall (m :: Type -> Type) block. (MonadSTM m, HasHeader block) => ChainDB block m -> STM m (Set (Point block))
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.
ChainDB | |
|
newtype SelectChain block Source #
Chain selection as a Monoid
.
SelectChain | |
|
Instances
HasHeader block => Monoid (SelectChain block) Source # | |
Defined in Test.Ouroboros.Network.Diffusion.Node.ChainDB mempty :: SelectChain block # mappend :: SelectChain block -> SelectChain block -> SelectChain block # mconcat :: [SelectChain block] -> SelectChain block # | |
HasHeader block => Semigroup (SelectChain block) Source # | |
Defined in Test.Ouroboros.Network.Diffusion.Node.ChainDB (<>) :: 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.