dfinity-radix-tree 0.5.0 → 0.5.1
raw patch · 6 files changed
+39/−13 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ DFINITY.RadixTree: getCheckpoint :: RadixTree database -> RadixRoot
+ DFINITY.RadixTree: getRoot :: RadixTree database -> RadixRoot
+ DFINITY.RadixTree: getValue :: RadixProof -> ByteString
Files
- CHANGELOG.md +5/−0
- dfinity-radix-tree.cabal +1/−1
- src/DFINITY/RadixTree.hs +16/−7
- src/DFINITY/RadixTree/Lenses.hs +16/−0
- src/DFINITY/RadixTree/Utilities.hs +0/−4
- test/Properties.hs +1/−1
CHANGELOG.md view
@@ -1,6 +1,11 @@+0.5.1 Enzo Haussecker <enzo@dfinity.org> Fri Oct 19 2018++ * Expose lens-based interface to radix tree data structures.+ 0.5.0 Enzo Haussecker <enzo@dfinity.org> Fri Oct 19 2018 * Implement Merkle proofs.+ * Reduce memory footprint of parallel download combinators. 0.4.0 Enzo Haussecker <enzo@dfinity.org> Tue Sep 25 2018
dfinity-radix-tree.cabal view
@@ -1,5 +1,5 @@ Name: dfinity-radix-tree-Version: 0.5.0+Version: 0.5.1 Synopsis: A generic data integrity layer. Description: This library allows you to construct a Merkle tree on top of any underlying
src/DFINITY/RadixTree.hs view
@@ -22,10 +22,15 @@ -- ** Types , RadixError(..)- , RadixProof(_radixValue)+ , RadixProof , RadixRoot , RadixTree + -- ** Getters+ , getCheckpoint+ , getRoot+ , getValue+ -- ** Create , createRadixTree @@ -43,6 +48,8 @@ -- ** Prove , createRadixProof++ -- ** Verify , verifyRadixProof -- ** Test@@ -50,11 +57,13 @@ , isValidRadixRoot -- ** Debug++ -- *** Contents , contentsRadixTree , contentsMerkleizedRadixTree , contentsNonMerkleizedRadixTree - -- ** Print+ -- *** Print , printRadixTree , printMerkleizedRadixTree , printNonMerkleizedRadixTree@@ -203,7 +212,7 @@ {-# SPECIALISE searchRadixTree :: Bool -> (RadixTree LevelDB.DB- -> ResourceT IO (Maybe (RadixNode, RadixCache)))+ -> ResourceT IO (Maybe (RadixNode, RadixCache))) -> ByteString -> RadixTree LevelDB.DB -> ResourceT IO (Either RadixError RadixSearchResult) #-}@@ -635,7 +644,7 @@ (validateKey, validateHashes) = maybe (False, False) id $ do keyBits <- recoverKey let root = NonEmpty.last _radixPath- pure $ (keyBits == toBits key, hashNode root == rootHash)+ pure $ (keyBits == toBits key, createRoot root == rootHash) recoverKey = do let childParents =@@ -653,7 +662,7 @@ -- decide if the implicit bit is 0 or 1 recoverBits (child, parent) = do let prefixBits = maybe [] toBits (_radixPrefix parent)- childHash = hashNode child+ childHash = createRoot child implicit0 = mfilter (== childHash) (_radixLeft parent) $> False implicit1 = mfilter (== childHash) (_radixRight parent) $> True @@ -767,7 +776,7 @@ {-# SPECIALISE contentsRadixTree' :: Bool -> (RadixTree LevelDB.DB- -> ResourceT IO (Maybe (RadixNode, RadixCache)))+ -> ResourceT IO (Maybe (RadixNode, RadixCache))) -> RadixTree LevelDB.DB -> ResourceT IO [(ByteString, ByteString)] #-} @@ -846,7 +855,7 @@ {-# SPECIALISE printRadixTree' :: Bool -> (RadixTree LevelDB.DB- -> ResourceT IO (Maybe (RadixNode, RadixCache)))+ -> ResourceT IO (Maybe (RadixNode, RadixCache))) -> RadixTree LevelDB.DB -> ResourceT IO () #-}
src/DFINITY/RadixTree/Lenses.hs view
@@ -12,6 +12,8 @@ , getChild , getChildren , getLeaf+ , getPath+ , getValue , getBloom , getBuffer , getCache@@ -34,11 +36,13 @@ import Data.Bool (bool) import Data.ByteString (ByteString)+import Data.List.NonEmpty (NonEmpty) import Lens.Simple (makeLenses, set, view) import DFINITY.RadixTree.Types makeLenses ''RadixNode+makeLenses ''RadixProof makeLenses ''RadixTree getPrefix :: RadixNode -> Maybe RadixPrefix@@ -59,6 +63,12 @@ getLeaf :: RadixNode -> Maybe ByteString getLeaf = view radixLeaf +getPath :: RadixProof -> NonEmpty RadixNode+getPath = view radixPath++getValue :: RadixProof -> ByteString+getValue = view radixValue+ getBloom :: RadixTree database -> RadixBloom getBloom = view radixBloom @@ -94,6 +104,12 @@ setLeaf :: Maybe ByteString -> RadixNode -> RadixNode setLeaf = set radixLeaf++setPath :: NonEmpty RadixNode -> RadixProof -> RadixProof+setPath = set radixPath++setValue :: ByteString -> RadixProof -> RadixProof+setValue = set radixValue setBloom :: RadixBloom -> RadixTree database -> RadixTree database setBloom = set radixBloom
src/DFINITY/RadixTree/Utilities.hs view
@@ -7,7 +7,6 @@ , createRootFromNonce , defaultRoot , ignoreIOErrors- , hashNode ) where import Codec.Serialise (serialise)@@ -45,6 +44,3 @@ ignoreIOErrors :: IO () -> IO () ignoreIOErrors = handle $ (const $ pure () :: IOError -> IO ())--hashNode :: RadixNode -> RadixRoot-hashNode = toShort . hash 20 mempty . toStrict . serialise
test/Properties.hs view
@@ -156,7 +156,7 @@ tree <- initTree tree' <- insertRadixTree k (mappend k "suffix") tree (_, mTree) <- merkleizeRadixTree tree'- fmap (_radixValue . fst) <$> createRadixProof k mTree + fmap (getValue . fst) <$> createRadixProof k mTree lookupRadix k = run $ do tree <- initTree