Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jun 21, 2018
1 parent 265223e commit dfb0a1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions shuffle/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def send(self, message):
print(message)
if message.startswith("Error"):
self.pThread.done.set()
elif message.startswith("Blame"):
if "insufficient" in message:
pass
elif "wrong hash" in message:
pass
else:
self.pThread.done.set()


def job():
logger = SimpleLogger()
Expand All @@ -38,14 +46,12 @@ def job():
if not pool.get("fool", False)
and pool.get("amount") == amount][0]
if members >= args.limit:
# network.start()
sleep(5)
pThread = ProtocolThread(host, port, network, amount, fee, sk, pubk, new_addr, change, logger=logger)
logger.pThread = pThread
pThread.start()
while not is_protocol_done(pThread):
sleep(1)
# network.stop()
pThread.join()
pThread = None
else:
Expand All @@ -67,8 +73,6 @@ def job():
parser.add_argument("-C", "--change", help="change address", type=str, required=True)
parser.add_argument("-T", "--period", help="period for checking the server in minutes", type=int, default=10)



args = parser.parse_args()
# Get network
config = SimpleConfig({})
Expand All @@ -87,7 +91,6 @@ def job():
# privkey
priv_key = args.key
sk, pubk = keys_from_priv(priv_key)
print(pubk)
# new address and change
new_addr = args.new_address
change = args.change
Expand All @@ -99,4 +102,4 @@ def job():

while True:
schedule.run_pending()
sleep(60)
sleep(30)
8 changes: 4 additions & 4 deletions shuffle/coin_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def __init__(self, coin, crypto, messages,
self.me = {players[player] : player for player in players}[self.vk]
else:
self.logchan('Error: publick key is not in the players list')
raise ValueError('My public key is not in players list')
# raise ValueError('My public key is not in players list')
else:
self.logchan.send('Error: same publick keys appears in the pool!')
raise ValueError('Same public keys appears!')
# raise ValueError('Same public keys appears!')
self.encryption_keys = dict()
self.new_addresses = set()
self.addr_new = addr_new
Expand Down Expand Up @@ -189,10 +189,10 @@ def blame_insufficient_funds(self):
self.number_of_players = len(self.players)
else:
self.logchan.send('Error: not enough players with sufficent funds')
raise Exception('Error: not enough players with sufficent funds')
# raise Exception('Error: not enough players with sufficent funds')
if self.vk in offenders:
self.logchan.send('Error: players funds is not enough')
raise Exception('Error: players funds is not enough')
# raise Exception('Error: players funds is not enough')
return False

def broadcast_new_key(self):
Expand Down

0 comments on commit dfb0a1c

Please sign in to comment.