Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Env = Env {
- envLedgerConfig ∷ HardForkLedgerConfig (BccEras StandardCrypto)
- envProtocolConfig ∷ ConsensusConfig (HardForkProtocol (BccEras StandardCrypto))
- envSecurityParam ∷ Env → Word64
- newtype LedgerState where
- LedgerState {
- clsState ∷ LedgerState (HardForkBlock (BccEras StandardCrypto))
- pattern LedgerStateCole ∷ LedgerState ColeBlock → LedgerState
- pattern LedgerStateSophie ∷ LedgerState (SophieBlock (SophieEra StandardCrypto)) → LedgerState
- pattern LedgerStateEvie ∷ LedgerState (SophieBlock (EvieEra StandardCrypto)) → LedgerState
- pattern LedgerStateJen ∷ LedgerState (SophieBlock (JenEra StandardCrypto)) → LedgerState
- LedgerState {
- initialLedgerState ∷ FilePath → ExceptT InitialLedgerStateError IO (Env, LedgerState)
- applyBlock ∷ Env → LedgerState → ValidationMode → Block era → Either Text LedgerState
- data ValidationMode
- applyBlockWithEvents ∷ Env → LedgerState → Bool → HardForkBlock (BccEras StandardCrypto) → Either Text LedgerStateEvents
- foldBlocks ∷ ∀ a. FilePath → ConsensusModeParams BccMode → FilePath → ValidationMode → a → (Env → LedgerState → BlockInMode BccMode → a → IO a) → ExceptT FoldBlocksError IO a
- chainSyncClientWithLedgerState ∷ ∀ m a. Monad m ⇒ Env → LedgerState → ValidationMode → ChainSyncClient (BlockInMode BccMode, Either Text LedgerState) ChainPoint ChainTip m a → ChainSyncClient (BlockInMode BccMode) ChainPoint ChainTip m a
- chainSyncClientPipelinedWithLedgerState ∷ ∀ m a. Monad m ⇒ Env → LedgerState → ValidationMode → ChainSyncClientPipelined (BlockInMode BccMode, Either Text LedgerState) ChainPoint ChainTip m a → ChainSyncClientPipelined (BlockInMode BccMode) ChainPoint ChainTip m a
- data FoldBlocksError
- data GenesisConfigError
- = NEError !Text
- | NEColeConfig !FilePath !ConfigurationError
- | NESophieConfig !FilePath !Text
- | NEAurumConfig !FilePath !Text
- | NEBccConfig !Text
- data InitialLedgerStateError
- renderFoldBlocksError ∷ FoldBlocksError → Text
- renderGenesisConfigError ∷ GenesisConfigError → Text
- renderInitialLedgerStateError ∷ InitialLedgerStateError → Text
Initialization / Accumulation
Env | |
|
envSecurityParam ∷ Env → Word64 Source #
newtype LedgerState Source #
LedgerState | |
|
pattern LedgerStateCole ∷ LedgerState ColeBlock → LedgerState | |
pattern LedgerStateSophie ∷ LedgerState (SophieBlock (SophieEra StandardCrypto)) → LedgerState | |
pattern LedgerStateEvie ∷ LedgerState (SophieBlock (EvieEra StandardCrypto)) → LedgerState | |
pattern LedgerStateJen ∷ LedgerState (SophieBlock (JenEra StandardCrypto)) → LedgerState |
∷ FilePath | Path to the bcc-node config file (e.g. to bcc-node projectconfigurationbcc/mainnet-config.json) |
→ ExceptT InitialLedgerStateError IO (Env, LedgerState) | The environment and initial ledger state |
Get the environment and initial ledger state.
∷ Env | The environment returned by |
→ LedgerState | The current ledger state |
→ ValidationMode | |
→ Block era | Some block to apply |
→ Either Text LedgerState | The new ledger state (or an error). |
Apply a single block to the current ledger state.
data ValidationMode Source #
How to do validation when applying a block to a ledger state.
FullValidation | Do all validation implied by the ledger layer's |
QuickValidation | Only check that the previous hash from the block matches the head hash of the ledger state. |
∷ Env | |
→ LedgerState | |
→ Bool | True to validate |
→ HardForkBlock (BccEras StandardCrypto) | |
→ Either Text LedgerStateEvents |
Traversing the block chain
∷ ∀ a. FilePath | Path to the bcc-node config file (e.g. to bcc-node projectconfigurationbcc/mainnet-config.json) |
→ ConsensusModeParams BccMode | This is needed for the number of slots per epoch for the Cole era (on mainnet that should be 21600). |
→ FilePath | Path to local bcc-node socket. This is the path specified by the |
→ ValidationMode | |
→ a | The initial accumulator state. |
→ (Env → LedgerState → BlockInMode BccMode → a → IO a) | Accumulator function Takes:
And returns:
Note: This function can safely assume no rollback will occur even though internally this is implemented with a client protocol that may require rollback. This is achieved by only calling the accumulator on states/blocks that are older than the security parameter, k. This has the side effect of truncating the last k blocks before the node's tip. |
→ ExceptT FoldBlocksError IO a | The final state |
Monadic fold over all blocks and ledger states. Stopping k
blocks before
the node's tip where k
is the security parameter.
chainSyncClientWithLedgerState Source #
∷ ∀ m a. Monad m | |
⇒ Env | |
→ LedgerState | Initial ledger state |
→ ValidationMode | |
→ ChainSyncClient (BlockInMode BccMode, Either Text LedgerState) ChainPoint ChainTip m a | A client to wrap. The block is annotated with a 'Either Text
LedgerState'. This is either an error from validating a block or
the current |
→ ChainSyncClient (BlockInMode BccMode) ChainPoint ChainTip m a | A client that acts just like the wrapped client but doesn't require the
|
Wrap a ChainSyncClient
with logic that tracks the ledger state.
chainSyncClientPipelinedWithLedgerState ∷ ∀ m a. Monad m ⇒ Env → LedgerState → ValidationMode → ChainSyncClientPipelined (BlockInMode BccMode, Either Text LedgerState) ChainPoint ChainTip m a → ChainSyncClientPipelined (BlockInMode BccMode) ChainPoint ChainTip m a Source #
Errors
data FoldBlocksError Source #
data GenesisConfigError Source #
NEError !Text | |
NEColeConfig !FilePath !ConfigurationError | |
NESophieConfig !FilePath !Text | |
NEAurumConfig !FilePath !Text | |
NEBccConfig !Text |
data InitialLedgerStateError Source #
ILSEConfigFile Text | Failed to read or parse the network config file. |
ILSEGenesisFile GenesisConfigError | Failed to read or parse a genesis file linked from the network config file. |
ILSELedgerConsensusConfig GenesisConfigError | Failed to derive the Ledger or Consensus config. |