From 2f74611844ec8d5054a6b90a67cbc54126c400aa Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 21 Jun 2019 02:22:38 -0400 Subject: [PATCH] pylint --- torba/torba/client/coinselection.py | 30 ++++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/torba/torba/client/coinselection.py b/torba/torba/client/coinselection.py index 953915b5f..87656ab3c 100644 --- a/torba/torba/client/coinselection.py +++ b/torba/torba/client/coinselection.py @@ -35,18 +35,16 @@ class CoinSelector: return getattr(self, strategy_name or "standard")(txos, available) @strategy - def prefer_confirmed( - self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], available: int - ) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: + def prefer_confirmed(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], + available: int) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: return ( self.only_confirmed(txos, available) or self.standard(txos, available) ) @strategy - def only_confirmed( - self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], _ - ) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: + def only_confirmed(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], + _) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: confirmed = [t for t in txos if t.txo.tx_ref and t.txo.tx_ref.height > 0] if not confirmed: return [] @@ -56,9 +54,8 @@ class CoinSelector: return self.standard(confirmed, confirmed_available) @strategy - def standard( - self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], available: int - ) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: + def standard(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], + available: int) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: return ( self.branch_and_bound(txos, available) or self.closest_match(txos, available) or @@ -66,9 +63,8 @@ class CoinSelector: ) @strategy - def branch_and_bound( - self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], available: int - ) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: + def branch_and_bound(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], + available: int) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: # see bitcoin implementation for more info: # https://github.com/bitcoin/bitcoin/blob/master/src/wallet/coinselection.cpp @@ -127,9 +123,8 @@ class CoinSelector: return [] @strategy - def closest_match( - self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], _ - ) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: + def closest_match(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], + _) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: """ Pick one UTXOs that is larger than the target but with the smallest change. """ target = self.target + self.cost_of_change smallest_change = None @@ -142,9 +137,8 @@ class CoinSelector: return [best_match] if best_match else [] @strategy - def random_draw( - self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], _ - ) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: + def random_draw(self, txos: List[basetransaction.BaseOutputEffectiveAmountEstimator], + _) -> List[basetransaction.BaseOutputEffectiveAmountEstimator]: """ Accumulate UTXOs at random until there is enough to cover the target. """ target = self.target + self.cost_of_change self.random.shuffle(txos, self.random.random)