remove duplicated checkpointAndCommit

pull/7/head
Iuri Matias 5 years ago
parent 7d5471508d
commit edd7879faf
  1. 13
      remix-lib/src/execution/execution-context.js
  2. 17
      remix-lib/src/execution/txRunner.js
  3. 15
      remix-simulator/src/genesis.js

@ -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)
})

Loading…
Cancel
Save