6. Settle a game โ
What is a settlement? โ
When a game finishes it has an outcome (of type t_outcome
). Each outcome is associated to a settlement (via settlements
) that is carried out. This consists in updating the channel bounds according to the thus specified transfers.
The game will be flagged as settled, so the game bonds cannot be opposed anymore to challenge a withdraw.
Settle a game โ
To be settled, a game must be pushed on-chain. It means that a newgame must have been pushed on-chain as well as the laststate.
Anyone can call the game_settle entrypoint.
@sp.entrypoint
def game_settle(self, game_id):
sp.set_type(game_id, sp.TBytes)
platform.game_settle(game_id).run(sender = player1)
Reminds on outcome
โ
Three types of outcomes exist:
player_double_played
: set bydouble_signed
ordouble_signed_offchain
player_inactive
: set bystarved
entrypointgame_finished
: set byapply_
lambda after aplay
or by the current.outcome ofupdate_state
Outcome value of player_double_played
and player_inactive
represents the id of the player associated with the fault. Outcome value of game_finished
is freely defined by the game.
A game without outcome can't be settled.
Transfers โ
Transfers are defined by the game constant settlements
. Each outcome and outcome value is associated with a list of transfers.
No transfer occurs if the outcome and outcome value aren't in settlements
.
A transfer decreases bonds of the sender and increases bonds of the receiver.
If the sender doesn't own enough to perform the transfer, the entire settlement fails.