vulpemventures / ocean

:ocean: Elements/Liquid wallet daemon
MIT License
5 stars 7 forks source link

Fix peristance of tx notifications #52

Closed altafan closed 1 year ago

altafan commented 1 year ago

This fixes how the app service persists the transaction received from the blockchain scanner by introducing a queue where all the received txs are pushed before being stored in the repository.

The reason is that for "multi account" txs, ie. those moving funds from one account to another, it happens that the same tx is sent over 2 different account channels barely at the same time and it's evident that it becomes problematic to persist the tx directly because of conflicts.

To prevent this, as mentioned, all txs received from the blockchain scanner are pushed to a queue that is emptied after 1 second the very first elem is added. This gives enough time to eventually update the account names of an already queued tx and allows the app svc to just add or confirm a tx in the repo without any extra operation that would slow even more this background process.