use ES6 class

pull/1/head
yann300 8 years ago
parent 4d79298d86
commit 8cc2a861e6
  1. 25
      src/app/execution-context.js

@ -21,30 +21,37 @@ if (typeof window.web3 !== 'undefined') {
/* /*
extend vm state manager and instanciate VM extend vm state manager and instanciate VM
*/ */
var stateManager = new StateManager({})
stateManager.keyHashes = {} class StateManagerCommonStorageDump extends StateManager {
var base = stateManager.putContractStorage constructor (arg) {
stateManager.putContractStorage = function (address, key, value, cb) { super(arg)
stateManager.keyHashes[ethUtil.sha3(key)] = ethUtil.bufferToHex(key) this.keyHashes = {}
base.apply(stateManager, [address, key, value, cb]) }
putContractStorage (address, key, value, cb) {
this.keyHashes[ethUtil.sha3(key)] = ethUtil.bufferToHex(key)
super.putContractStorage(address, key, value, cb)
} }
stateManager.dumpStorage = function (address, cb) { dumpStorage (address, cb) {
stateManager._getStorageTrie(address, function (err, trie) { var self = this
this._getStorageTrie(address, function (err, trie) {
if (err) { if (err) {
return cb(err) return cb(err)
} }
var storage = {} var storage = {}
var stream = trie.createReadStream() var stream = trie.createReadStream()
stream.on('data', function (val) { stream.on('data', function (val) {
storage[stateManager.keyHashes[val.key]] = val.value.toString('hex') storage[self.keyHashes[val.key]] = val.value.toString('hex')
}) })
stream.on('end', function () { stream.on('end', function () {
cb(storage) cb(storage)
}) })
}) })
} }
}
var stateManager = new StateManagerCommonStorageDump({})
var vm = new EthJSVM({ var vm = new EthJSVM({
enableHomestead: true, enableHomestead: true,
activatePrecompiles: true activatePrecompiles: true

Loading…
Cancel
Save