From 19e8aa1b1c4ce0a5eefa9fa7c05fbce1a9483747 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 21 Jan 2015 14:27:25 +0000 Subject: [PATCH] Add the ability for games to earmark part of the house balance This allows games to take bets from players (so the players aren't in control of them anymore) while still not counting these as part of the house balance (and thus the house can't spend them on some other payment). --- tipbot/betutils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tipbot/betutils.py b/tipbot/betutils.py index b766636..a51ad9a 100644 --- a/tipbot/betutils.py +++ b/tipbot/betutils.py @@ -231,6 +231,13 @@ def RetrieveHouseBalance(): house_balance = house_balance - ib user_balances+=ib + earmarked_balances=0 + earmarked = redis_hgetall("earmarked") + for e in earmarked: + eb = long(redis_hget("earmarked", e)) + house_balance = house_balance - eb + earmarked_balances+=eb + rbal=long(redis_get('reserve_balance') or 0) if rbal: house_balance = house_balance - rbal @@ -238,7 +245,7 @@ def RetrieveHouseBalance(): if house_balance < 0: raise RuntimeError('Negative house balance') return - log_info('RetrieveHouseBalance: unlocked %s, users %s, reserve %s, house %s' % (AmountToString(unlocked_balance), AmountToString(user_balances), AmountToString(rbal), AmountToString(house_balance))) + log_info('RetrieveHouseBalance: unlocked %s, users %s, earmarked %s, reserve %s, house %s' % (AmountToString(unlocked_balance), AmountToString(user_balances), AmountToString(earmarked_balances), AmountToString(rbal), AmountToString(house_balance))) return house_balance def GetHouseBalance(link,cmd):