Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Storage.ChainDB.API.Types.InvalidBlockPunishment
Contents
Description
How to punish the sender of a invalid block
Synopsis
- data InvalidBlockPunishment m
- enact :: InvalidBlockPunishment m -> Invalidity -> m ()
- data Invalidity
- branch :: ( Invalidity -> InvalidBlockPunishment m) -> InvalidBlockPunishment m
- mkPunishThisThread :: IOLike m => m ( InvalidBlockPunishment m)
- mkUnlessImproved :: forall proxy m blk. ( IOLike m, NoThunks ( SelectView ( BlockProtocol blk)), Ord ( SelectView ( BlockProtocol blk))) => proxy blk -> STM m ( SelectView ( BlockProtocol blk) -> InvalidBlockPunishment m -> InvalidBlockPunishment m)
- noPunishment :: Applicative m => InvalidBlockPunishment m
opaque
data InvalidBlockPunishment m Source #
How to handle a discovered
Invalidity
This type is opaque because the soundness of the punishment is subtle because of where it is invoked during the chain selection. As a result, arbitrary monadic actions would be foot guns. Instead, this module defines a small DSL for punishment that we judge to be sound.
Instances
enact :: InvalidBlockPunishment m -> Invalidity -> m () Source #
combinators
data Invalidity Source #
Is the added block itself invalid, or is its prefix invalid?
Constructors
BlockItself | |
BlockPrefix |
branch :: ( Invalidity -> InvalidBlockPunishment m) -> InvalidBlockPunishment m Source #
Punish according to the
Invalidity
mkPunishThisThread :: IOLike m => m ( InvalidBlockPunishment m) Source #
Create a punishment that kills this thread
mkUnlessImproved :: forall proxy m blk. ( IOLike m, NoThunks ( SelectView ( BlockProtocol blk)), Ord ( SelectView ( BlockProtocol blk))) => proxy blk -> STM m ( SelectView ( BlockProtocol blk) -> InvalidBlockPunishment m -> InvalidBlockPunishment m) Source #
Allocate a stateful punishment that performs the given punishment unless the given header is better than the previous invocation
noPunishment :: Applicative m => InvalidBlockPunishment m Source #
A noop punishment