add Listen on last block API

pull/7/head
yann300 7 years ago
parent 9d4cbb79df
commit 2f3651a548
  1. 17
      remix-lib/src/execution/execution-context.js

@ -83,6 +83,9 @@ function ExecutionContext () {
var executionContext = null var executionContext = null
this.blockGasLimitDefault = 4300000
this.blockGasLimit = this.blockGasLimitDefault
this.init = function (config) { this.init = function (config) {
if (config.get('settings/always-use-vm')) { if (config.get('settings/always-use-vm')) {
executionContext = 'vm' executionContext = 'vm'
@ -184,10 +187,13 @@ function ExecutionContext () {
return this.blockGasLimit return this.blockGasLimit
} }
this.blockGasLimitDefault = 4300000 this.stopListenOnLastBlock = function () {
this.blockGasLimit = this.blockGasLimitDefault if (this.listenOnLastBlockId) clearInterval(this.listenOnLastBlockId)
// removing the setinterval cause it cause tape test to hang and we don't need this. this.listenOnLastBlockId = null
// there's a copy of this file in remix-ide repo @TODO to refactor }
this.listenOnLastBlock = function () {
this.listenOnLastBlockId = setInterval(() => {
if (this.getProvider() !== 'vm') { if (this.getProvider() !== 'vm') {
web3.eth.getBlock('latest', (err, block) => { web3.eth.getBlock('latest', (err, block) => {
if (!err) { if (!err) {
@ -196,6 +202,8 @@ function ExecutionContext () {
} else { } else {
this.blockGasLimit = this.blockGasLimitDefault this.blockGasLimit = this.blockGasLimitDefault
} }
}, 15000)
}
}) })
} }
@ -224,4 +232,3 @@ function ExecutionContext () {
} }
module.exports = new ExecutionContext() module.exports = new ExecutionContext()

Loading…
Cancel
Save