aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/core.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/core.go')
-rw-r--r--internal/casino/core.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/casino/core.go b/internal/casino/core.go
index 4177094..7ac728f 100644
--- a/internal/casino/core.go
+++ b/internal/casino/core.go
@@ -130,13 +130,13 @@ func (c *tableCore[P]) refundAllLocked() []Event {
// settleStakeOutcome applies one wager's outcome through the wallet and
// reports whether the settlement could NOT be made durable. It carries the
// money-critical ordering shared by every table game (documented in
-// building_guide/concurrency.md): compute the payout, pay it via
-// PayStakeCover BEFORE announcing the win (that one save both credits the
-// payout and removes the stakes it returns), and only then stand the hand
-// down. On a persistence failure the stakes stay pending, so a later shutdown
-// refund or startup recovery returns them exactly once — the payout was never
-// durable, so it can never be paid on top of the refund. The caller must not
-// announce a paid win and must not run the player-wide ResolveStakes.
+// building_guide/concurrency.md): compute the payout, pay it via PayCredits
+// BEFORE announcing the win — that one save credits the payout and resolves
+// the stakes it returns, so a crash can never pay the payout AND refund the
+// same stake — and only then stand the hand down. On a persistence failure
+// the stakes stay pending, so a later shutdown refund or startup recovery
+// returns them exactly once. The caller must not announce a paid win and must
+// not run the player-wide ResolveStakes.
//
// payoutErr is a payout-computation error (for example an overflowed
// multiplier): it is treated exactly like a persistence failure so a
@@ -150,10 +150,10 @@ func settleStakeOutcome(w Wallet, payout int, stakeIDs []string, payoutErr error
return false
}
if payout > 0 {
- if err := w.PayStakeCover(payout, stakeIDs); err != nil {
- return true
- }
+ return w.PayCredits(payout, stakeIDs...) != nil
}
+ // A zero payout is a loss: consume the stakes so recovery cannot refund a
+ // round that resolved.
for _, id := range stakeIDs {
if id != "" {
w.ResolveStake(id)