I reworked the handler a bit. The main addititon in the transactionWorker similiar to how the resendTransaction goroutine was working in the previous iteration. Now all the transactions are being processed by this worker which will retrieve the transaction from the transactionQueue which unde the hood is a heap prioritizing over the minimum nonce. That means that everytime we want to retrieve a transaction it will return the one with the lowest nonce.
The workflow is prety straightforward. Everytime an adressNonceHandler is created, such a goroutine transactionWorker.start() that will poll the transactionQueue will start. When SendTransaction is called, the transaction passed in the arguments will end in the queue and futher processed by the transactionWorker and futher send the road.
By doing this we make sure to always send transactions in order, there are some caveats to it that will need to be addressed though.
I reworked the handler a bit. The main addititon in the
transactionWorker
similiar to how the resendTransaction goroutine was working in the previous iteration. Now all the transactions are being processed by this worker which will retrieve the transaction from thetransactionQueue
which unde the hood is a heap prioritizing over the minimum nonce. That means that everytime we want to retrieve a transaction it will return the one with the lowest nonce.The workflow is prety straightforward. Everytime an
adressNonceHandler
is created, such a goroutinetransactionWorker.start()
that will poll thetransactionQueue
will start. WhenSendTransaction
is called, the transaction passed in the arguments will end in the queue and futher processed by thetransactionWorker
and futher send the road.By doing this we make sure to always send transactions in order, there are some caveats to it that will need to be addressed though.