tdex-network / tdex-daemon-alpha

💰 Alpha Daemon implementation to run automated market making strategies on top of TDEX
MIT License
0 stars 2 forks source link

Support concurrent swap requests #15

Open tiero opened 4 years ago

tiero commented 4 years ago

The best strategy to achieve this would be to keep a local collection unspents for utxos (the crawler component should keep this in sync watching the chain continuously) and to create a sort of spendings collection that resembles the concept in databases of the "write-ahead log".

When a new swap it's taken and accepted by the daemon, both the unspents and the spendings collection need to be atomically updated, respectively "logically deleting" the unspent "to be consumed" by the swap in the former and inserting a "sort of" new utxo in the latter. (I say sort of because we wouldn't have yet a txid field like in the unspesnts one, but we are interested only in the value and asset field)

The balances endpoint would need to calculate the real available balance aggregating the two collection, NOT only looking in the unspents colelction, but both.

tiero commented 4 years ago

cc/ @altafan

tiero commented 4 years ago

cc/ @lukekhamilton