From 8fe46e5a54cb9fd6bfc88592003c4bc465f73d64 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 2 Feb 2018 00:08:57 +0000 Subject: [PATCH] Introduce stateManager.copy() and use that in VM.copy() --- lib/index.js | 5 +---- lib/stateManager.js | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) 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) {