Commit 627e624a authored by yann300's avatar yann300

fix loop setup txlistener

parent 4dd7f3f5
...@@ -62,10 +62,11 @@ class TxListener { ...@@ -62,10 +62,11 @@ class TxListener {
this.loopId = 'vm-listener' this.loopId = 'vm-listener'
} else { } else {
this.loopId = setInterval(() => { this.loopId = setInterval(() => {
var currentLoopId = this.loopId
executionContext.web3().eth.getBlockNumber((error, blockNumber) => { executionContext.web3().eth.getBlockNumber((error, blockNumber) => {
if (this.loopId === null || this.loopId === 'vm-listener') return if (this.loopId === null || this.loopId === 'vm-listener') return
if (error) return console.log(error) if (error) return console.log(error)
if (!this.lastBlock || blockNumber > this.lastBlock) { if (currentLoopId === this.loopId && (!this.lastBlock || blockNumber > this.lastBlock)) {
this.lastBlock = blockNumber this.lastBlock = blockNumber
executionContext.web3().eth.getBlock(this.lastBlock, true, (error, result) => { executionContext.web3().eth.getBlock(this.lastBlock, true, (error, result) => {
if (!error) { if (!error) {
...@@ -74,7 +75,7 @@ class TxListener { ...@@ -74,7 +75,7 @@ class TxListener {
}) })
} }
}) })
}, 2) }, 2000)
} }
} }
......
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