xaya / libxayagame

MIT License
21 stars 19 forks source link

Allow multiple moves per txid #112

Closed domob1812 closed 2 years ago

domob1812 commented 3 years ago

In the context of Xaya X and for instance an Ethereum-based smart contract for Xaya, it will be possible to trigger multiple move events from a single transaction. The current libxayagame logic for tracking pending moves assumes that a txid maps to at most one move, so this will break.

We need to make sure that the pending logic maps transaction IDs to one or more moves, and uses that when updating / constructing the pending state (in particular, when matching it against the mempool list of txids).

domob1812 commented 2 years ago

For situations where a single txid has more than one associated move, we will allow the game-pending-move ZMQ notification data to be a JSON array rather than JSON object. In that situation, all entries should correspond to moves generated by a single transaction (e.g. same txid), and the whole list will replace whatever data is cached for that txid already (if any).

This ensures that we can properly handle multiple moves per txid, do so in a manner compatible with the existing Xaya Core ZMQ interface and also handle situations where the moves corresponding to one txid actually change (as they could on a smart-contract system like Polygon).