fix listening on new block

pull/5370/head
yann300 3 years ago
parent f4ecd649e4
commit e62f88527d
  1. 5
      libs/remix-lib/src/execution/txListener.ts

@ -133,7 +133,7 @@ export class TxListener {
*/ */
init () { init () {
this.blocks = [] this.blocks = []
this.lastBlock = null this.lastBlock = -1
} }
/** /**
@ -170,8 +170,7 @@ export class TxListener {
this.executionContext.web3().eth.getBlockNumber((error, blockNumber) => { this.executionContext.web3().eth.getBlockNumber((error, blockNumber) => {
if (this._loopId === null) return if (this._loopId === null) return
if (error) return console.log(error) if (error) return console.log(error)
if (currentLoopId === this._loopId && (!this.lastBlock || blockNumber > this.lastBlock)) { if (currentLoopId === this._loopId && blockNumber > this.lastBlock) {
if (!this.lastBlock) this.lastBlock = blockNumber - 1
let current = this.lastBlock + 1 let current = this.lastBlock + 1
this.lastBlock = blockNumber this.lastBlock = blockNumber
while (blockNumber >= current) { while (blockNumber >= current) {

Loading…
Cancel
Save