From 6ef18fbbaecfc3d4e92b2f77baaab885bd3ff2ed Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Fri, 11 Nov 2016 19:21:24 +0100 Subject: [PATCH] Simplify Transaction.to_inputs method --- bigchaindb/common/transaction.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/bigchaindb/common/transaction.py b/bigchaindb/common/transaction.py index c1857d23..9bcb5e1f 100644 --- a/bigchaindb/common/transaction.py +++ b/bigchaindb/common/transaction.py @@ -786,20 +786,14 @@ class Transaction(object): :obj:`list` of :class:`~bigchaindb.common.transaction. Fulfillment` """ - inputs = [] - if condition_indices is None or len(condition_indices) == 0: - # NOTE: If no condition indices are passed, we just assume to - # take all conditions as inputs. - condition_indices = [index for index, _ - in enumerate(self.conditions)] - - for cid in condition_indices: - input_cond = self.conditions[cid] - ffill = Fulfillment(input_cond.fulfillment, - input_cond.owners_after, - TransactionLink(self.id, cid)) - inputs.append(ffill) - return inputs + # NOTE: If no condition indices are passed, we just assume to + # take all conditions as inputs. + return [ + Fulfillment(self.conditions[cid].fulfillment, + self.conditions[cid].owners_after, + TransactionLink(self.id, cid)) + for cid in condition_indices or range(len(self.conditions)) + ] def add_fulfillment(self, fulfillment): """Adds a Fulfillment to a Transaction's list of Fulfillments.