git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 6fe142caac2b90a38153c18db7efe3c687a39a75

switch back to borc

Norton Wang committed on 3/8/2018, 8:45:39 PM
Parent: b3e32df171921ad8cbc02f8ac9c39e05f2d8f4ab

Files changed

package.jsonchanged
systemObjects.jschanged
package.jsonView
@@ -30,9 +30,9 @@
3030 "contributors": "Alex Beregszaszi <alex@rtfs.hu>",
3131 "license": "MPL-2.0",
3232 "dependencies": {
3333 "binary-search-insert": "^1.0.3",
34- "cbor": "^4.0.0",
34+ "borc": "^2.0.2",
3535 "events": "^2.0.0",
3636 "reference-map": "^1.2.3",
3737 "safe-buffer": "^5.1.1",
3838 "wasm-json-toolkit": "^0.2.2",
systemObjects.jsView
@@ -1,5 +1,5 @@
1-const cbor = require('cbor')
1+const cbor = require('borc')
22
33 const TAGS = {
44 id: 41,
55 link: 42,
@@ -27,22 +27,23 @@
2727 class Serializable {
2828 serialize () {
2929 const encoder = new cbor.Encoder()
3030 this.encodeCBOR(encoder)
31- return encoder.read().toString('hex')
31+ return encoder.finalize()
3232 }
3333
3434 static deserialize (serialized) {
35- decoder.push(Buffer.from(serialized, 'hex'))
36- return decoder.read()
35+ return decoder.decodeFirst(serialized)
3736 }
3837 }
3938
4039 class FunctionRef extends Serializable {
4140 constructor (privateFunc, identifier, params, id, gas=0) {
4241 super()
4342 this.private = privateFunc
4443 this.identifier = identifier
44+ if (!(id instanceof ID))
45+ id = new ID(id)
4546 this.destId = id
4647 this.params = params
4748 this.gas = gas
4849 }
@@ -51,10 +52,9 @@
5152 return gen.write(new cbor.Tagged(TAGS.func, [
5253 this.private,
5354 this.identifier,
5455 this.params,
55- this.destId,
56- this.gas
56+ this.destId
5757 ]))
5858 }
5959
6060 set container (container) {

Built with git-ssb-web