Unverified Commit 20e54006 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #701 from yann300/executionContext_ListenOnLastBlock

Execution context: listen on last block API
parents 8f6cd8f9 2f3651a5
...@@ -83,6 +83,9 @@ function ExecutionContext () { ...@@ -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 () { ...@@ -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 () { ...@@ -196,6 +202,8 @@ function ExecutionContext () {
} else { } else {
this.blockGasLimit = this.blockGasLimitDefault this.blockGasLimit = this.blockGasLimitDefault
} }
}, 15000)
}
}) })
} }
...@@ -224,4 +232,3 @@ function ExecutionContext () { ...@@ -224,4 +232,3 @@ function ExecutionContext () {
} }
module.exports = new ExecutionContext() module.exports = new ExecutionContext()
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