multiversx / mx-sdk-go

MultiversX GO SDK for interacting with the MultiversX blockchain (in general) and Smart Contracts (in particular).
GNU General Public License v3.0
18 stars 12 forks source link

NonceHandlerV3 #169

Closed cristure closed 6 months ago

cristure commented 8 months ago

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.