From 077d3edc627f2c67479923b4ee68c30513fc561e Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Tue, 16 Aug 2016 19:45:44 +0300 Subject: [PATCH] allow taker to wait for commitments; switched on for tumbler. bugfix to choose_sweep_orders --- joinmarket/configure.py | 2 +- joinmarket/support.py | 8 ++++---- joinmarket/taker.py | 12 +++++++++--- tumbler.py | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/joinmarket/configure.py b/joinmarket/configure.py index a3a5954b..21404f19 100644 --- a/joinmarket/configure.py +++ b/joinmarket/configure.py @@ -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 diff --git a/joinmarket/support.py b/joinmarket/support.py index b9675c1d..72f14d1b 100644 --- a/joinmarket/support.py +++ b/joinmarket/support.py @@ -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 diff --git a/joinmarket/taker.py b/joinmarket/taker.py index 813b77d3..bbe42e37 100644 --- a/joinmarket/taker.py +++ b/joinmarket/taker.py @@ -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 diff --git a/tumbler.py b/tumbler.py index e1d1d124..67fa20a5 100644 --- a/tumbler.py +++ b/tumbler.py @@ -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)