0.0.0 • Published 8 years ago

merkle-trie v0.0.0

Weekly downloads
4
License
MPL-2.0
Repository
github
Last release
8 years ago

SYNOPSIS

NPM Package Build Status Coverage Status

js-standard-style

A merkle trie implemention that if focused on being generic and fast backed by IPFS

INSTALL

npm install merkle-trie

USAGE

const store = new Store()
const newVertex = new Vertex({
  store: store
})
const path = ['not', 'all', 'those', 'who', 'wanderer', 'are', 'lost']
const value = 'all that is gold does not glitter'

newVertex.set(path, new Vertex({
  value: value
}))

newVertex.get(path)
.then(vertex => {
  // retrieves the vertex that was stored
  // saves all the work done on the trie to the store
  // and return the merkle link to the root vertex
  return newVertex.flush()
}).then(cid => {
  // get the vertex from the store
  return store.get(cid)
}).then(vertex => {
  // the vertex returned from the store
  return vertex.get(path)
}).then(vertex => {
  console.log(vertex.value) // all that is gold does not glitter
})

NOTES

Operations that mutate the trie (set and delete) are synchronous while operations that return values (get, update) are asynchronous. This is because writing operations are written to a cache. And the cache is only written to the store when flush is called. The idea here is to avoid doing lookups and hashing until it is absolutely necessary.

Store is just a instance of ipld-resolver that uses promises instead of callbacks.

API

TESTS

npm run tests

LICENSE

MPL-2.0

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago