git ssb

0+

wanderer🌟 / js-dfinity-radix-tree



Commit f360b75824e9bd1e15f8928424e85e42326fda49

fix link encoding

wanderer committed on 3/22/2018, 7:16:17 PM
Parent: e61d25798db079eb20435ebc17b0e9f1f2da20fa

Files changed

datastore.jschanged
datastore.jsView
@@ -5,8 +5,15 @@
55 const cbor = require('borc')
66
77 module.exports = class TreeDAG extends DAG {
88 async put (val) {
9+ if (val[1]) {
10+ val[1] = new cbor.Tagged(42, val[1]['/'])
11+ }
12+
13+ if (val[2]) {
14+ val[2] = new cbor.Tagged(42, val[2]['/'])
15+ }
916 const encoded = cbor.encode(val)
1017 const key = await TreeDAG.getMerkleLink(encoded)
1118
1219 return new Promise((resolve, reject) => {
@@ -23,8 +30,15 @@
2330 reject(err)
2431 } else {
2532 val = Buffer.from(val, 'hex')
2633 const decoded = cbor.decode(val)
34+ if (decoded[1]) {
35+ decoded[1]['/'] = decoded[1].value
36+ }
37+
38+ if (decoded[2]) {
39+ decoded[2]['/'] = decoded[2].value
40+ }
2741 resolve(decoded)
2842 }
2943 })
3044 })

Built with git-ssb-web