Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
allow taker to wait for commitments; switched on for tumbler. bugfix …
Browse files Browse the repository at this point in the history
…to choose_sweep_orders
  • Loading branch information
AdamISZ committed Aug 16, 2016
1 parent c6c67ba commit 077d3ed
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion joinmarket/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __getitem__(self, key):
global_singleton.config = SafeConfigParser()
global_singleton.config_location = 'joinmarket.cfg'
global_singleton.commit_file_location = 'cmttools/commitments.json'

global_singleton.wait_for_commitments = 0

def jm_single():
return global_singleton
Expand Down
8 changes: 4 additions & 4 deletions joinmarket/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,11 @@ def calc_zero_change_cj_amount(ordercombo):
orders_fees = sorted(orders_fees, key=feekey)
chosen_orders = []
while len(chosen_orders) < n:
if len(orders_fees) < n - len(chosen_orders):
log.debug('ERROR not enough liquidity in the orderbook')
# TODO handle not enough liquidity better, maybe an Exception
return None, 0, 0
for i in range(n - len(chosen_orders)):
if len(orders_fees) < n - len(chosen_orders):
log.debug('ERROR not enough liquidity in the orderbook')
# TODO handle not enough liquidity better, maybe an Exception
return None, 0, 0
chosen_order, chosen_fee = chooseOrdersBy(orders_fees, n)
log.debug('chosen = ' + str(chosen_order))
# remove all orders from that same counterparty
Expand Down
12 changes: 9 additions & 3 deletions joinmarket/taker.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ def get_commitment(self, utxos, amount):
"""Create commitment to fulfil anti-DOS requirement of makers,
storing the corresponding reveal/proof data for next step.
"""
self.commitment, self.reveal_commitment = \
self.commitment_creator(self.wallet, utxos, amount)
while True:
self.commitment, self.reveal_commitment = self.commitment_creator(
self.wallet, utxos, amount)
if (self.commitment) or (jm_single().config.getint(
"POLICY", "wait_for_commitments") == 0):
break
log.debug("Failed to source commitments, waiting 3 minutes")
time.sleep(3 * 60)
if not self.commitment:
log.debug("Cannot construct transaction, failed to generate "
"commitment, shutting down. Please read commitments_debug.txt"
"commitment, shutting down. Please read commitments_debug.txt "
"for some information on why this is, and what can be "
"done to remedy it.")
#TODO: would like to raw_input here to show the user, but
Expand Down
2 changes: 1 addition & 1 deletion tumbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def main():
wallet = Wallet(wallet_file,
max_mix_depth=options['mixdepthsrc'] + options['mixdepthcount'])
jm_single().bc_interface.sync_wallet(wallet)

jm_single().config.set("POLICY", "wait_for_commitments", "1")
log.debug('starting tumbler')
mcs = [IRCMessageChannel(c) for c in get_irc_mchannels()]
mcc = MessageChannelCollection(mcs)
Expand Down

0 comments on commit 077d3ed

Please sign in to comment.