Skip to content

Commit 8fe46e5

Browse files
axicholgerd77
authored andcommitted
Introduce stateManager.copy() and use that in VM.copy()
1 parent 9bc99c3 commit 8fe46e5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ VM.prototype.runCall = require('./runCall.js')
8080
VM.prototype.runBlockchain = require('./runBlockchain.js')
8181

8282
VM.prototype.copy = function () {
83-
return new VM({
84-
state: this.trie.copy(),
85-
blockchain: this.blockchain
86-
})
83+
return new VM({ stateManager: this.stateManager.copy() })
8784
}
8885

8986
/**

lib/stateManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ function StateManager (opts) {
3333

3434
var proto = StateManager.prototype
3535

36+
proto.copy = function () {
37+
return new StateManager({ trie: this.trie.copy(), blockchain: this.blockchain })
38+
}
39+
3640
// gets the account from the cache, or triggers a lookup and stores
3741
// the result in the cache
3842
proto.getAccount = function (address, cb) {

0 commit comments

Comments
 (0)