dfinity-radix-tree-0.2.1: A generic data integrity layer.

Copyright2018 DFINITY Stiftung
LicenseGPL-3
MaintainerEnzo Haussecker <enzo@dfinity.org>
StabilityStable
Safe HaskellNone
LanguageHaskell2010

Network.DFINITY.RadixTree

Contents

Description

A generic data integrity layer.

Synopsis

Class

class Monad m => RadixDatabase m database where Source #

Minimal complete definition

load, store

Methods

load :: database -> ByteString -> m (Maybe ByteString) Source #

store :: database -> ByteString -> ByteString -> m () Source #

Types

data RadixError Source #

Instances
Eq RadixError Source # 
Instance details

Defined in Network.DFINITY.RadixTree.Types

Data RadixError Source # 
Instance details

Defined in Network.DFINITY.RadixTree.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RadixError -> c RadixError #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RadixError #

toConstr :: RadixError -> Constr #

dataTypeOf :: RadixError -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RadixError) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RadixError) #

gmapT :: (forall b. Data b => b -> b) -> RadixError -> RadixError #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RadixError -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RadixError -> r #

gmapQ :: (forall d. Data d => d -> u) -> RadixError -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RadixError -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RadixError -> m RadixError #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RadixError -> m RadixError #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RadixError -> m RadixError #

Show RadixError Source # 
Instance details

Defined in Network.DFINITY.RadixTree.Types

Exception RadixError Source # 
Instance details

Defined in Network.DFINITY.RadixTree.Types

data RadixTree database Source #

Create

createRadixTree Source #

Arguments

:: 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.

subtreeRadixTree Source #

Arguments

:: RadixDatabase m database 
=> RadixRoot

State root.

-> RadixTree database

Radix tree.

-> m (RadixTree database) 

Create a radix tree from a radix tree.

Insert

insertRadixTree Source #

Arguments

:: RadixDatabase m database 
=> ByteString

Key.

-> ByteString

Value.

-> RadixTree database

Radix tree.

-> m (RadixTree database) 

Insert a key and value into a radix tree.

Delete

deleteRadixTree Source #

Arguments

:: RadixDatabase m database 
=> ByteString

Key.

-> RadixTree database

Radix tree.

-> m (RadixTree database) 

Delete a value from a radix tree.

Merkleize

merkleizeRadixTree Source #

Arguments

:: RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m (RadixRoot, RadixTree database) 

Merkleize a radix tree. This will flush the buffer to disk.

Query

lookupRadixTree Source #

Arguments

:: RadixDatabase m database 
=> ByteString

Key.

-> RadixTree database

Radix tree.

-> m (Maybe (ByteString, RadixTree database)) 

A convenient alias for lookupNonMerkleizedRadixTree.

lookupMerkleizedRadixTree Source #

Arguments

:: RadixDatabase m database 
=> ByteString

Key.

-> RadixTree database

Radix tree.

-> m (Maybe (ByteString, RadixTree database)) 

Deprecated: The function is will be removed in the next release. Please use lookupRadixTree instead.

Lookup a value in a Merkleized radix tree.

lookupNonMerkleizedRadixTree Source #

Arguments

:: RadixDatabase m database 
=> ByteString

Key.

-> RadixTree database

Radix tree.

-> m (Maybe (ByteString, RadixTree database)) 

Lookup a value in a non-Merkleized radix tree.

Test

isEmptyRadixTree Source #

Arguments

:: RadixTree database

Radix tree.

-> Bool 

Check if a radix tree is empty.

isValidRadixRoot Source #

Arguments

:: RadixDatabase m database 
=> RadixRoot

State root.

-> RadixTree database

Radix tree.

-> m Bool 

Check if a state root is valid.

Stream

sourceMerkleizedRadixTree Source #

Arguments

:: MonadResource m 
=> RadixDatabase (ConduitM () ByteString m) database 
=> [Bool]

Bit mask.

-> Int

LRU cache size in items.

-> BoundedChan RadixRoot

Terminal state root producer.

-> RadixTree database

Radix tree.

-> ConduitM () ByteString m () 

Create a conduit from a Merkleized radix tree.

sinkMerkleizedRadixTree Source #

Arguments

:: MonadResource m 
=> RadixDatabase (ConduitM ByteString () m) database 
=> RadixRoot

Target state root.

-> BoundedChan RadixRoot

Terminal state root consumer.

-> RadixTree database

Radix tree.

-> ConduitM ByteString () m (Either [RadixRoot] (RadixTree database)) 

Create a Merkleized radix tree from a conduit.

Debug

contentsRadixTree Source #

Arguments

:: RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m [(ByteString, ByteString)] 

A convenient alias for contentsNonMerkleizedRadixTree.

contentsMerkleizedRadixTree Source #

Arguments

:: RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m [(ByteString, ByteString)] 

Get the contents of a Merkleized radix tree.

contentsNonMerkleizedRadixTree Source #

Arguments

:: RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m [(ByteString, ByteString)] 

Get the contents of a non-Merkleized radix tree.

printRadixTree Source #

Arguments

:: MonadIO m 
=> RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m () 

A convenient alias for printNonMerkleizedRadixTree.

printMerkleizedRadixTree Source #

Arguments

:: MonadIO m 
=> RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m () 

Print a Merkleized radix tree.

printNonMerkleizedRadixTree Source #

Arguments

:: MonadIO m 
=> RadixDatabase m database 
=> RadixTree database

Radix tree.

-> m () 

Print a non-Merkleized radix tree.