summaryrefslogtreecommitdiffstats
path: root/docs/GAMES.md
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-29 21:36:26 +0100
committersalmonik <salmonik@tuta.io>2026-10-29 21:36:26 +0100
commit772727b0ef7d63144bf629d774f8b6c1c996bf78 (patch)
tree1680dbbd61fce2aaf383ee81ad04ff0705ffe985 /docs/GAMES.md
parentv2.3.0: add crash with local multiplier and pushed crash event (diff)
downloadzagan-bet-772727b0ef7d63144bf629d774f8b6c1c996bf78.tar.gz
zagan-bet-772727b0ef7d63144bf629d774f8b6c1c996bf78.zip
v2.3.1: settle orphaned reservations on server restart
Diffstat (limited to 'docs/GAMES.md')
-rw-r--r--docs/GAMES.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/GAMES.md b/docs/GAMES.md
index 844d1b0..2b8adf5 100644
--- a/docs/GAMES.md
+++ b/docs/GAMES.md
@@ -137,6 +137,34 @@ plays (
137The balance update and the `plays` insert happen in one transaction 137The balance update and the `plays` insert happen in one transaction
138(`database::apply_play`). 138(`database::apply_play`).
139 139
140### Reserved bets and restarts
141
142Blackjack and crash reserve the bet before the round can settle. The debit and
143a `pending_plays` row are written in one transaction
144(`database::reserve_play`); settling deletes that row and writes the `plays`
145audit row in the same transaction.
146
147```
148pending_plays (
149 session_id TEXT PRIMARY KEY,
150 username TEXT NOT NULL,
151 game_type TEXT NOT NULL,
152 bet_amount INTEGER NOT NULL,
153 details TEXT NOT NULL DEFAULT '{}',
154 created_at DATETIME DEFAULT CURRENT_TIMESTAMP
155)
156```
157
158If the server dies with a round in flight, the reservation survives the process.
159The next startup calls `recover_orphaned_reservations` before the listener
160accepts connections, and each leftover is settled as a **forfeit**: the bet is
161not refunded, and the audit row gets `winnings = 0`,
162`details.result = "abandoned"`, `details.reason = "server_restart"`.
163
164The sweep runs once per process, never per connection. A per-connection sweep
165would settle another player's live hand, and only one server process may own a
166database.
167
140## Wire protocol 168## Wire protocol
141 169
142Slots keeps its original exchange: 170Slots keeps its original exchange: