diff --git a/lib/index.js b/lib/index.js index 9652e5f9a8..71b03e93d4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -80,10 +80,7 @@ VM.prototype.runCall = require('./runCall.js') VM.prototype.runBlockchain = require('./runBlockchain.js') VM.prototype.copy = function () { - return new VM({ - state: this.trie.copy(), - blockchain: this.blockchain - }) + return new VM({ stateManager: this.stateManager.copy() }) } /** diff --git a/lib/stateManager.js b/lib/stateManager.js index 4bd9b35d20..b1663c6c7d 100644 --- a/lib/stateManager.js +++ b/lib/stateManager.js @@ -33,6 +33,10 @@ function StateManager (opts) { var proto = StateManager.prototype +proto.copy = function () { + return new StateManager({ trie: this.trie.copy(), blockchain: this.blockchain }) +} + // gets the account from the cache, or triggers a lookup and stores // the result in the cache proto.getAccount = function (address, cb) {