One of the most important commits in this stack. Added code that allows us to handle transactional device list updates. Adding/removing devices should generate a new device list (and in the future sign it), while keeping previous ones in database, to have its full history.
The transaction goes as follows:
- Previous device list timestamp is fetched from database (user table)
- All user's current devices are fetched from database (device table)
- A caller-defined function is called to:
- Mutably modify the "current devices"
- Return a database update to be performed in transaction
- A new device list is generated from the modified "current devices" (with new timestamp)
- The database update is performed in transaction:
- Current devices are updated (closure-returned DDB operation is performed)
- New device list is inserted with new timestamp
- The timestamp in user table is updated to the new device list timestamp
- Previous timestamp is checked to be equal to the one fetched in step 1. Transaction fails on mismatch
Depends on D10218