Compare commits

...

3 Commits

Author SHA1 Message Date
vulpine 18dc6fd808 dont devide by zero 2020-09-02 12:05:15 -04:00
vulpine 10d1e6e5d7 correct total calculation 2020-09-02 12:02:01 -04:00
vulpine 8ce353c074 replace transaction tax with wealth tax 2020-09-02 11:16:54 -04:00
1 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import modules.identify as ident
import asyncio
async def bal(self):
bals = {'bank':self.initfund}
bals = {}
for t in self.ledger:
await asyncio.sleep(0) # yeild control as this is a long operation
t['amount'] = float(t['amount'])
@ -14,12 +14,16 @@ async def bal(self):
if t['to'] not in bals:
bals[t['to']]=0.00
if bals[t['sender']] - t['amount'] < 0.0:
if t['sender'] != 'bank' and bals[t['sender']] - t['amount'] < 0.0:
self.ledger.delete(id=t['id'])
continue # no debt for you
bals[t['sender']] += 0 - t['amount']
bals[t['to']] += t['amount'] * 0.99
bals['bank'] += t['amount'] * 0.01
bals[t['to']] += t['amount']
for i in bals:
bals['bank'] += bals[i] * 0.001
bals[i] -= bals[i] * 0.001
self.initfund = abs(bals['bank'])
return bals
async def send(self,c,n,m):
@ -73,8 +77,7 @@ async def richest(self,c,n,m):
async def init(self):
self.ledger = self.db['ledger']
self.initfund = 137.0
self.initfund = 1
self.cmd['sendcoins'] = send
self.cmd['balance'] = balance