Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Validated
- data Unvalidated
- data Blockchain a
- blockchainConfig :: Blockchain a -> BlockchainConfig
- blockchainNode :: Blockchain a -> BlockchainNode
- data BlockchainNode = BlockchainNode {
- nodeBlock :: Block
- nodeNodes :: [BlockchainNode]
- data ValidationException
- data BlockException
- = BlockAlreadyExists
- | NoParentFound
- | TimestampTooOld
- | TimestampTooFarIntoFuture
- | InvalidDifficultyReference
- | InvalidDifficulty
- | InvalidCoinbaseTransactionHash
- | InvalidTransactionHashTreeRoot
- | InvalidCoinbaseTransactionValue
- | InvalidTransactionValues
- | TransactionOutRefNotFound
- | InvalidTransactionSignature
- construct :: BlockchainConfig -> BlockchainNode -> Blockchain Unvalidated
- validate :: Blockchain Unvalidated -> Either ValidationException (Blockchain Validated)
- addBlock :: Block -> Blockchain Validated -> Either BlockException (Blockchain Validated)
- validateTransaction :: Blockchain Validated -> Transaction -> Either BlockException ()
- validateTransactions :: Blockchain Validated -> [Transaction] -> Either BlockException ()
- blockHeaderHashDifficulty :: Hex256 -> BlockHeader -> Difficulty
- addressValues :: Blockchain Validated -> HashMap PublicKey Word
- unspentTransactionOutputs :: Blockchain Validated -> HashMap PublicKey [(TransactionOutRef, TransactionOut)]
- longestChain :: Blockchain Validated -> NonEmpty Block
- flatten :: Blockchain Validated -> NonEmpty (NonEmpty Block)
Documentation
data Unvalidated Source #
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
or Blockchain
Validated
.Blockchain
Unvalidated
Note: both
and Blockchain
Validated
can be serialized to json,
while only Blockchain
Unvalidated
can be deserialized from json.Blockchain
Unvalidated
Eq (Blockchain a) Source # | |
Show (Blockchain a) Source # | |
Generic (Blockchain a) Source # | |
ToJSON (Blockchain a) Source # | |
FromJSON (Blockchain Unvalidated) Source # | |
type Rep (Blockchain a) Source # | |
blockchainNode :: Blockchain a -> BlockchainNode Source #
data BlockchainNode Source #
data ValidationException Source #
data BlockException Source #
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
validateTransaction :: Blockchain Validated -> Transaction -> Either BlockException () Source #
validateTransactions :: Blockchain Validated -> [Transaction] -> Either BlockException () Source #