git ssb

0+

wanderer🌟 / js-dfinity-radix-tree



Commit 27ff705435b6458d192cfb844027d32cd144a183

don't rehash root

wanderer committed on 3/22/2018, 12:58:23 AM
Parent: 3cd983ac8d618fa6a28393d6beee5e609408ded4

Files changed

datastore.jschanged
tests/index.jschanged
datastore.jsView
@@ -5,8 +5,11 @@
55 const cbor = require('borc')
66
77 module.exports = class TreeDAG extends DAG {
88 async put (val) {
9+ if (TreeDAG.isValidLink(val)) {
10+ return val
11+ }
912 const encoded = cbor.encode(val)
1013 const key = await TreeDAG.getMerkleLink(encoded)
1114
1215 return new Promise((resolve, reject) => {
tests/index.jsView
@@ -3,8 +3,19 @@
33 const level = require('level-browserify')
44 const RadixTree = require('../')
55 const db = level('./testdb')
66
7+tape.only('set and get', async t => {
8+ let tree = new RadixTree({
9+ db: db
10+ })
11+ const stateRoot = await tree.flush()
12+ console.log(stateRoot)
13+ const stateRoot2 = await tree.flush()
14+ console.log(stateRoot2)
15+ t.end()
16+})
17+
718 tape('set and get', async t => {
819 const r = await RadixTree.getMerkleLink(Buffer.from([0]))
920
1021 t.equal(r.toString('hex'), '6e340b9cffb37a989ca544e6bb780a2c78901d3f', 'should hash')

Built with git-ssb-web