def filter_orderbook(self, orderbook, sweep=False): if sweep: self.orderbook = orderbook #offers choosing deferred to next step else: self.orderbook, self.total_cj_fee = choose_orders( orderbook, self.cjamount, self.n_counterparties, self.order_chooser, self.ignored_makers) if self.orderbook is None: #Failure to get an orderbook means order selection failed #for some reason; no action is taken, we let the stallMonitor # + the finished callback decide whether to retry. return False if self.filter_orders_callback: accepted = self.filter_orders_callback( [self.orderbook, self.total_cj_fee], self.cjamount) if accepted == "retry": #Special condition if Taker is "determined to continue" #(such as tumbler); even though these offers are rejected, #we don't trigger the finished callback; see above note on #`if self.orderbook is None` return False if not accepted: self.on_finished_callback(False) return False return True
def filter_orderbook(self, orderbook, sweep=False): #If honesty filter is set, we immediately filter to only the prescribed #honest makers before continuing. In this case, the number of #counterparties should already match, and this has to be set by the #script instantiating the Taker. #Note: If one or more of the honest makers has dropped out in the meantime, #we will just have insufficient offers and it will fail in the usual way #for insufficient liquidity. if self.honest_only: orderbook = [ o for o in orderbook if o['counterparty'] in self.honest_makers ] if sweep: self.orderbook = orderbook #offers choosing deferred to next step else: if self.wallet_service.get_txtype() == "p2pkh": allowed_types = ["reloffer", "absoffer"] elif self.wallet_service.get_txtype() == "p2sh-p2wpkh": allowed_types = ["swreloffer", "swabsoffer"] elif self.wallet_service.get_txtype() == "p2wpkh": allowed_types = ["sw0reloffer", "sw0absoffer"] else: jlog.error("Unrecognized wallet type, taker cannot continue.") return False self.orderbook, self.total_cj_fee = choose_orders( orderbook, self.cjamount, self.n_counterparties, self.order_chooser, self.ignored_makers, allowed_types=allowed_types, max_cj_fee=self.max_cj_fee) if self.orderbook is None: #Failure to get an orderbook means order selection failed #for some reason; no action is taken, we let the stallMonitor # + the finished callback decide whether to retry. return False if self.filter_orders_callback: accepted = self.filter_orders_callback( [self.orderbook, self.total_cj_fee], self.cjamount) if accepted == "retry": #Special condition if Taker is "determined to continue" #(such as tumbler); even though these offers are rejected, #we don't trigger the finished callback; see above note on #`if self.orderbook is None` return False if not accepted: return False return True