handleRegisteringBallot and handleCastingBallot will read the bock number using web3.eth.getBlockNumber() assuming the transaction they are waiting for as not been mined already.
But if there are lots of ballot messages, the corresponding transaction could have been mined before we get a chance to watch its events. Thus, the step will never end because the block number will be too high already.
Instead of calling web3.eth.getBlockNumber() in handleRegisteringBallot and handleCastingBallot, it should be read in the previous step, saved in the ballot message object and fetched back when required.
handleRegisteringBallot
andhandleCastingBallot
will read the bock number usingweb3.eth.getBlockNumber()
assuming the transaction they are waiting for as not been mined already.But if there are lots of ballot messages, the corresponding transaction could have been mined before we get a chance to watch its events. Thus, the step will never end because the block number will be too high already.
Instead of calling
web3.eth.getBlockNumber()
inhandleRegisteringBallot
andhandleCastingBallot
, it should be read in the previous step, saved in the ballot message object and fetched back when required.Exemple: