Commit edd7879f authored by Iuri Matias's avatar Iuri Matias

remove duplicated checkpointAndCommit

parent 7d547150
......@@ -220,6 +220,19 @@ function ExecutionContext () {
}
}
this.checkpointAndCommit = function (cb, checkpointCount) {
if (this.vm().stateManager._checkpointCount > (checkpointCount || 0)) {
return this.vm().stateManager.commit(() => {
cb()
})
}
this.vm().stateManager.checkpoint(() => {
this.vm().stateManager.commit(() => {
cb()
})
})
}
this.currentblockGasLimit = function () {
return this.blockGasLimit
}
......
......@@ -135,7 +135,7 @@ class TxRunner {
executionContext.vm().stateManager.checkpoint(() => { })
}
this.checkpointAndCommit(() => {
executionContext.checkpointAndCommit(() => {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function (err, results) {
err = err ? err.message : err
if (err) {
......@@ -157,20 +157,7 @@ class TxRunner {
transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash()))
})
})
})
}
checkpointAndCommit (cb) {
if (executionContext.vm().stateManager._checkpointCount > 1) {
return executionContext.vm().stateManager.commit(() => {
cb()
})
}
executionContext.vm().stateManager.checkpoint(() => {
executionContext.vm().stateManager.commit(() => {
cb()
})
})
}, 1)
}
runInNode (from, to, data, value, gasLimit, useCall, confirmCb, gasEstimationForceSend, promptCb, callback) {
......
......@@ -4,19 +4,6 @@ var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN
function checkpointAndCommit (cb) {
if (executionContext.vm().stateManager._checkpointCount > 0) {
return executionContext.vm().stateManager.commit(() => {
cb()
})
}
executionContext.vm().stateManager.checkpoint(() => {
executionContext.vm().stateManager.commit(() => {
cb()
})
})
}
function generateBlock () {
var block = new EthJSBlock({
header: {
......@@ -30,7 +17,7 @@ function generateBlock () {
uncleHeaders: []
})
checkpointAndCommit(() => {
executionContext.checkpointAndCommit(() => {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function () {
executionContext.addBlock(block)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment