ClientStorage
Client storage boundary.
transaction must be atomic: if transaction's block throws, none of its writes become visible; otherwise all of them do. Ratchet state is updated together with the encrypt/decrypt work, and a consumed one-time prekey is removed together with storing the session it created. A remote identity is pinned in the same transaction that stores the first session with it. A replaced session and the retired initiation are written together. A sent message becomes pending together with the ratchet step that encrypted it; a received message becomes pending inbound together with the ratchet step that decrypted it. A commit or a discard removes the pending inbound message and records its terminal tombstone together. An accepted identity change replaces the pin, removes the session and retires its initiation together.
Rules for the block:
Use the receiver's stores, not those of the outer storage object.
A nested
transactioncall on the receiver joins the running transaction.No network I/O or other long suspension: the transaction holds a lock.
Do not switch threads. SQLite drivers bind a transaction to its thread.
Store calls outside transaction act as single-call transactions.