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
- type RadixRoot = ShortByteString
- data RadixTree database
- 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))
- 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
MonadIO m => RadixDatabase m DB Source # | |
Defined in Network.DFINITY.RadixTree.Types load :: DB -> ByteString -> m (Maybe ByteString) Source # store :: DB -> ByteString -> ByteString -> m () Source # | |
Monad m => RadixDatabase (StateT (Map ByteString ByteString) m) () Source # | |
Defined in Network.DFINITY.RadixTree.Types load :: () -> ByteString -> StateT (Map ByteString ByteString) m (Maybe ByteString) Source # store :: () -> ByteString -> ByteString -> StateT (Map ByteString ByteString) m () Source # |
Types
data RadixError Source #
Instances
type RadixRoot = ShortByteString 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.
Test
:: RadixDatabase m database | |
=> RadixRoot | State root. |
-> RadixTree database | Radix tree. |
-> m Bool |
Check if a state root is valid.
Debug
:: 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.