git ssb

0+

wanderer🌟 / js-dfinity-radix-tree



Commit 4143b5779d03c5527c674008885b39d94cfd76ec

added readme

wanderer committed on 8/4/2017, 10:27:09 PM
Parent: 0a2ff8de9be467a416ae023a6257e799a5db796f

Files changed

README.mdadded
README.mdView
@@ -1,0 +1,72 @@
1 +[![NPM Package](https://img.shields.io/npm/v/merkle-radix-tree.svg?style=flat-square)](https://www.npmjs.org/package/merkle-radix-tree)
2 +[![Build Status](https://img.shields.io/travis/wanderer/merkle-radix-tree.svg?branch=master&style=flat-square)](https://travis-ci.org/wanderer/merkle-radix-tree)
3 +[![Coverage Status](https://img.shields.io/coveralls/wanderer/merkle-radix-tree.svg?style=flat-square)](https://coveralls.io/wanderer/merkle-radix-tree)
4 +
5 +[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
6 +
7 +# install
8 +`npm install merkle-radix-tree`
9 +
10 +# SYNOPSIS
11 +This implements a binary merkle radix tree. The point of using a binary radix
12 +tree is that it generates smaller proof size then trees with larger radixes.
13 +This tree is well suited for storing large dictonaries of fairly random key. If
14 +the keys are not random better performance can be achived by hashing them first.
15 +
16 +# INSTALL
17 +`npm install merkle-radix-tree`
18 +
19 +# USAGE
20 +
21 +```javascript
22 +const IPFS = require('ipfs')
23 +const RadixTree = require('merkle-radix-tree')
24 +
25 +// start ipfs
26 +const node = new IPFS({
27 + start: false,
28 + repo: './ipfs-repo'
29 +})
30 +
31 +node.on('ready', async () => {
32 + const prover = new RadixTree({
33 + dag: node.dag
34 + })
35 +
36 + // set some values
37 + await prover.set('test', 'value')
38 + await prover.set('doge', 'coin')
39 + await prover.set('cat', 'dog')
40 + await prover.set('monkey', 'wrench')
41 +
42 + // create a merkle root and save the tree
43 + const merkleRoot = await prover.flush()
44 +
45 + // start a new Instance with the root
46 + const verifier = new RadixTree({
47 + dag: node.dag,
48 + root: merkleRoot
49 + })
50 +
51 + // gets the merkle proof from ipfs-js and returns the result
52 + const val = await verifier.get('monkey')
53 + console.log(val)
54 +})
55 +```
56 +# API
57 +['./docs/'](./docs/index.md)
58 +
59 +# SPEC
60 +['./docs/spec.md']('./docs/spec.md')
61 +
62 +# BENCHMARKS
63 +The result of the benchmarks show that the binary radix tree produces proofs on
64 +average %67 small then Ethereum Trie with 100000 keys stored.
65 +
66 +['./benchmarks/benchmarks.md']('./docs/spec.md')
67 +
68 +# TESTS
69 +`npm run tests`
70 +
71 +# LICENSE
72 +[MPL-2.0](https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2))

Built with git-ssb-web