B7.4.3 · dive 3 of 3 · module B7.4
Settlement strategies.
A live room settles continuously as the board moves; a blind room settles once at the close with a single idempotent batch that pays the top entrants by accuracy from the bank, guarded by a claim so a retry pays no one twice.
The idea
codemojex · settlement strategiesHow a game pays out depends on its mode. A live room settles continuously: each scored guess updates the standings, the board moves, and a player sees their rank shift in the moment. There is no separate payout step beyond keeping the sorted set current, because the standing itself is the result.
A blind room settles once, at the close. When the timer ends, a single batch pass reads the final standings and pays the top entrants by accuracy — the most-accurate few share the bank that every paid attempt funded. Nothing is paid before the close, which is what lets the blind mode hold its silence and still be fair to a late entrant.
A batch payout has to be idempotent, because a close can fire more than once and a node can retry. The reference implementation guards the settlement with a claim — a single marker that the game has settled — so the pass runs to completion exactly once and a winner is paid one time. The claim and the standings live in Valkey; the settled outcome and the balances are written to Postgres as the record of truth.
The doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, and the 3.0 Stream Tier — XADD, XREADGROUP, XACK — with conformance on Valkey.
Redis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, locks, and streams — the judgement layer.
/echo-persistenceEcho Persistence — the durable floor
Beneath the volatile tiers: the Graft page engine built twice, the commit-LSN loop, and the stream archive on Tigris. Where Part I says state lives somewhere, this says where it lives durably.
References
sources · relatedSources
- All-pay auctions — every bid is paid, the standings decide the prizethe bank funded by every paid attempt, paid out to the top entrants
- Kreps — The Log: real-time data’s unifying abstractiona leaderboard and a settlement recomputable from the recorded guesses
- Easley & Kleinberg — Networks, Crowds, and Markets, ch. 9the sealed, pay-the-top settlement a blind room runs at the close
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus