Commit c6b8d8c5 authored by yann300's avatar yann300

don't miss block if block time low

parent 584170d0
...@@ -67,18 +67,31 @@ class TxListener { ...@@ -67,18 +67,31 @@ class TxListener {
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 (currentLoopId === this.loopId && (!this.lastBlock || blockNumber > this.lastBlock)) { if (currentLoopId === this.loopId && (!this.lastBlock || blockNumber > this.lastBlock)) {
if (!this.lastBlock) this.lastBlock = blockNumber - 1
var current = this.lastBlock + 1
this.lastBlock = blockNumber this.lastBlock = blockNumber
executionContext.web3().eth.getBlock(this.lastBlock, true, (error, result) => { while (blockNumber >= current) {
if (!error) { try {
this._newBlock(Object.assign({type: 'web3'}, result)) this._manageBlock(current)
} catch (e) {
console.log(e)
} }
}) current++
}
} }
}) })
}, 2000) }, 2000)
} }
} }
_manageBlock (blockNumber) {
executionContext.web3().eth.getBlock(blockNumber, true, (error, result) => {
if (!error) {
this._newBlock(Object.assign({type: 'web3'}, result))
}
})
}
/** /**
* stop listening for incoming transactions. do not reset the recorded pool. * stop listening for incoming transactions. do not reset the recorded pool.
* *
......
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