Skip to content

Commit

Permalink
leb128 encode nonce
Browse files Browse the repository at this point in the history
Signed-off-by: wanderer <mjbecze@gmail.com>
  • Loading branch information
wanderer committed Dec 2, 2017
1 parent c8b8cb6 commit 6b00321
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 53 deletions.
7 changes: 5 additions & 2 deletions actor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const Buffer = require('safe-buffer').Buffer
const Message = require('primea-message')
const leb128 = require('leb128').unsigned
const LockMap = require('lockmap')
const Inbox = require('./inbox.js')

Expand All @@ -15,7 +17,7 @@ module.exports = class Actor {
constructor (opts) {
// console.log(opts.state)
this.state = opts.state
this.nonce = opts.state.root['/'][3][2]
this.nonce = leb128.decode(opts.state.root['/'][3].subarray(2))
this.hypervisor = opts.hypervisor
this.id = opts.id
this.container = new opts.container.Constructor(this, opts.container.args)
Expand Down Expand Up @@ -95,7 +97,8 @@ module.exports = class Actor {
*/
shutdown () {
// save the nonce
this.state.root['/'][3][2] = this.nonce
let state = this.state.root['/'][3].subarray(0, 2)
this.state.root['/'][3] = Buffer.concat([state, leb128.encode(this.nonce)])
this.hypervisor.scheduler.done(this.id)
}

Expand Down
2 changes: 1 addition & 1 deletion inbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const binarySearchInsert = require('binary-search-insert')
const Buffer = require('safe-buffer').Buffer
const binarySearchInsert = require('binary-search-insert')

// decides which message to go first
function messageArbiter (messageA, messageB) {
Expand Down
52 changes: 3 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"license": "MPL-2.0",
"dependencies": {
"binary-search-insert": "^1.0.3",
"leb128": "0.0.4",
"lockmap": "^0.1.0",
"primea-message": "0.6.1",
"safe-buffer": "^5.1.1",
Expand All @@ -40,7 +41,7 @@
},
"devDependencies": {
"coveralls": "^3.0.0",
"dfinity-radix-tree": "0.0.5",
"dfinity-radix-tree": "0.0.7",
"documentation": "^5.3.3",
"level-browserify": "^1.1.1",
"nyc": "^11.3.0",
Expand Down

0 comments on commit 6b00321

Please sign in to comment.