From 3820d43eecb342a9170d289471eb746521c54e65 Mon Sep 17 00:00:00 2001 From: Vanshdeep Singh Date: Fri, 17 Aug 2018 10:40:23 +0000 Subject: [PATCH] fixed memorize bug --- bigchaindb/common/transaction.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bigchaindb/common/transaction.py b/bigchaindb/common/transaction.py index 7feaf6dd..53ba0abd 100644 --- a/bigchaindb/common/transaction.py +++ b/bigchaindb/common/transaction.py @@ -63,8 +63,12 @@ def memoize_class(func): @functools.wraps(func) def memoized_func(*args, **kwargs): - key = args[0].id - if key not in cache: + key = args[0]._id + if key is None: + result = func(*args, **kwargs) + cache[result['id']] = result + return result + elif key not in cache: cache[key] = func(*args, **kwargs) return cache[key] @@ -1146,8 +1150,7 @@ class Transaction(object): return self._id def to_hash(self): - return self.id - # return self.to_dict()['id'] + return self.to_dict()['id'] @staticmethod def _to_str(value):