Skip to content

Commit 27ff705

Browse files
author
wanderer
committed
don't rehash root
1 parent 3cd983a commit 27ff705

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

datastore.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ 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

tests/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ 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

0 commit comments

Comments
 (0)