git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 560a2364b7318ac4511c7e50913ac0bcc9bbe7b6

move actor id generation to its own method

Norton Wang committed on 4/16/2018, 9:02:33 PM
Parent: d0a5ea25b9d19aad6f2be59441be57da023c9c70

Files changed

index.jschanged
index.jsView
@@ -76,11 +76,9 @@
7676 * @param {Object} id - the id for the actor
7777 */
7878 createActor (type, code, id = {nonce: this.nonce++, parent: null}) {
7979 const Container = this._containerTypes[type]
80- const encoded = encodedID(id)
81- id = this._hash(encoded)
82- id = new ID(id)
80+ id = this.generateId(id)
8381 const module = Container.onCreation(code, id)
8482 const metaData = [type, 0]
8583
8684 // save the container in the state
@@ -100,8 +98,14 @@
10098 module
10199 }
102100 }
103101
102+ generateId (id) {
103+ const encoded = encodedID(id)
104+ const hashed = this._hash(encoded)
105+ return new ID(hashed)
106+ }
107+
104108 _hash (buf) {
105109 const hash = crypto.createHash('sha256')
106110 hash.update(buf)
107111 return hash.digest().slice(0, 20)

Built with git-ssb-web