don't miss block if block time low

pull/1/head
yann300 7 years ago
parent 584170d033
commit c6b8d8c5aa
  1. 21
      src/app/execution/txListener.js

@ -67,18 +67,31 @@ class TxListener {
if (this.loopId === null || this.loopId === 'vm-listener') return
if (error) return console.log(error)
if (currentLoopId === this.loopId && (!this.lastBlock || blockNumber > this.lastBlock)) {
if (!this.lastBlock) this.lastBlock = blockNumber - 1
var current = this.lastBlock + 1
this.lastBlock = blockNumber
executionContext.web3().eth.getBlock(this.lastBlock, true, (error, result) => {
if (!error) {
this._newBlock(Object.assign({type: 'web3'}, result))
while (blockNumber >= current) {
try {
this._manageBlock(current)
} catch (e) {
console.log(e)
}
})
current++
}
}
})
}, 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.
*

Loading…
Cancel
Save