| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Blockchain.Core.Blockchain
- 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 #
Instances
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
Instances
| 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 #
Constructors
| BlockchainNode | |
Fields
| |
data ValidationException Source #
Constructors
| GenesisBlockHasTransactions | |
| GenesisBlockException BlockException | |
| BlockValidationException BlockException |
Instances
data BlockException Source #
Constructors
Instances
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 #