Copyright | 2018 DFINITY Stiftung |
---|---|
License | GPL-3 |
Maintainer | Enzo Haussecker <enzo@dfinity.org> |
Stability | Stable |
Safe Haskell | None |
Language | Haskell2010 |
A generic data integrity layer.
Synopsis
- class Monad m => RadixDatabase m database where
- data RadixError
- data RadixProof
- type RadixRoot = ShortByteString
- data RadixTree database
- getCheckpoint :: RadixTree database -> RadixRoot
- getRoot :: RadixTree database -> RadixRoot
- getValue :: RadixProof -> ByteString
- createRadixTree :: RadixDatabase m database => Int -> Int -> Maybe RadixRoot -> database -> m (RadixTree database)
- insertRadixTree :: RadixDatabase m database => ByteString -> ByteString -> RadixTree database -> m (RadixTree database)
- deleteRadixTree :: RadixDatabase m database => ByteString -> RadixTree database -> m (RadixTree database)
- merkleizeRadixTree :: RadixDatabase m database => RadixTree database -> m (RadixRoot, RadixTree database)
- lookupRadixTree :: RadixDatabase m database => ByteString -> RadixTree database -> m (Maybe (ByteString, RadixTree database))
- createRadixProof :: RadixDatabase m database => ByteString -> RadixTree database -> m (Maybe (RadixProof, RadixTree database))
- verifyRadixProof :: ByteString -> RadixRoot -> RadixProof -> Bool
- isEmptyRadixTree :: RadixTree database -> Bool
- isValidRadixRoot :: RadixDatabase m database => RadixRoot -> RadixTree database -> m Bool
- contentsRadixTree :: RadixDatabase m database => RadixTree database -> m [(ByteString, ByteString)]
- contentsMerkleizedRadixTree :: RadixDatabase m database => RadixTree database -> m [(ByteString, ByteString)]
- contentsNonMerkleizedRadixTree :: RadixDatabase m database => RadixTree database -> m [(ByteString, ByteString)]
- printRadixTree :: MonadIO m => RadixDatabase m database => RadixTree database -> m ()
- printMerkleizedRadixTree :: MonadIO m => RadixDatabase m database => RadixTree database -> m ()
- printNonMerkleizedRadixTree :: MonadIO m => RadixDatabase m database => RadixTree database -> m ()
Class
class Monad m => RadixDatabase m database where Source #
load :: database -> ByteString -> m (Maybe ByteString) Source #
store :: database -> ByteString -> ByteString -> m () Source #
Instances
Types
data RadixError Source #
Instances
data RadixProof Source #
Instances
type RadixRoot = ShortByteString Source #
Getters
getCheckpoint :: RadixTree database -> RadixRoot Source #
getValue :: RadixProof -> ByteString Source #
Create
:: RadixDatabase m database | |
=> Int | Bloom filter size in bits. |
-> Int | LRU cache size in items. |
-> Maybe RadixRoot | Previous state root. |
-> database | Database. |
-> m (RadixTree database) |
Create a radix tree.
Insert
:: RadixDatabase m database | |
=> ByteString | Key. |
-> ByteString | Value. |
-> RadixTree database | Radix tree. |
-> m (RadixTree database) |
Insert a value into a radix tree.
Delete
:: RadixDatabase m database | |
=> ByteString | Key. |
-> RadixTree database | Radix tree. |
-> m (RadixTree database) |
Delete a value from a radix tree.
Merkleize
:: RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m (RadixRoot, RadixTree database) |
Merkleize a radix tree. This will flush the buffer to the database.
Query
:: RadixDatabase m database | |
=> ByteString | Key. |
-> RadixTree database | Radix tree. |
-> m (Maybe (ByteString, RadixTree database)) |
Lookup a value in a radix tree.
Prove
:: RadixDatabase m database | |
=> ByteString | Key. |
-> RadixTree database | Radix tree. |
-> m (Maybe (RadixProof, RadixTree database)) |
Prove that a value exists in a radix tree.
Verify
:: ByteString | Key. |
-> RadixRoot | State root. |
-> RadixProof | Radix proof. |
-> Bool |
Verify that a value exists in a radix tree.
Test
:: RadixDatabase m database | |
=> RadixRoot | State root. |
-> RadixTree database | Radix tree. |
-> m Bool |
Check if a state root is valid.
Debug
Contents
:: RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m [(ByteString, ByteString)] |
A convenient alias for contentsNonMerkleizedRadixTree
.
contentsMerkleizedRadixTree Source #
:: RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m [(ByteString, ByteString)] |
Get the contents of a Merkleized radix tree.
contentsNonMerkleizedRadixTree Source #
:: RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m [(ByteString, ByteString)] |
Get the contents of a non-Merkleized radix tree.
:: MonadIO m | |
=> RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m () |
A convenient alias for printNonMerkleizedRadixTree
.
printMerkleizedRadixTree Source #
:: MonadIO m | |
=> RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m () |
Print a Merkleized radix tree.
printNonMerkleizedRadixTree Source #
:: MonadIO m | |
=> RadixDatabase m database | |
=> RadixTree database | Radix tree. |
-> m () |
Print a non-Merkleized radix tree.