blockchain-0.0.2: Generic blockchain implementation.

Safe HaskellNone
LanguageHaskell2010

Data.Blockchain.Core.Blockchain

Contents

Synopsis

Documentation

data Blockchain a Source #

Core blockchain data type. Uses a validation tag to declare if it is known to abide by expected blockchain rules. Will be either Blockchain Validated or Blockchain Unvalidated.

Note: both Blockchain Validated and Blockchain Unvalidated can be serialized to json, while only Blockchain Unvalidated can be deserialized from json.

Construction

construct :: BlockchainConfig -> BlockchainNode -> Blockchain Unvalidated Source #

Constructs an unvalidated blockchain from a config and a node. Allows arbitrary blockchains to be constructed. However, blockchains are generally not useful until validated.

validate :: Blockchain Unvalidated -> Either ValidationException (Blockchain Validated) Source #

Validates a blockchain. Returns a ValidationException if provided blockchain does not meet expected rules.

addBlock :: Block -> Blockchain Validated -> Either BlockException (Blockchain Validated) Source #

Adds a block to a validated blockchain. Returns a BlockException if block is not able to be inserted into the blockchain.

Validation

Chain inspection