Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- mkForDiffusionPipelining ∷ ∀ m blk. (IOLike m, BlockSupportsDiffusionPipelining blk) ⇒ STM m (BlockConfig blk → Header blk → InvalidBlockPunishment m → InvalidBlockPunishment m)
- mkPunishThisThread ∷ IOLike m ⇒ 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?
branch ∷ (Invalidity → InvalidBlockPunishment m) → InvalidBlockPunishment m Source #
Punish according to the Invalidity
mkForDiffusionPipelining ∷ ∀ m blk. (IOLike m, BlockSupportsDiffusionPipelining blk) ⇒ STM m (BlockConfig blk → Header blk → InvalidBlockPunishment m → InvalidBlockPunishment m) Source #
Allocate a stateful punishment that performs the given punishment if the given header does not satisfy the diffusion pipelining criterion.
mkPunishThisThread ∷ IOLike m ⇒ m (InvalidBlockPunishment m) Source #
Create a punishment that kills this thread
noPunishment ∷ Applicative m ⇒ InvalidBlockPunishment m Source #
A noop punishment