Skip to content

Commit

Permalink
fix: store items duplicate check
Browse files Browse the repository at this point in the history
  • Loading branch information
sschiessl-bcp authored Jan 23, 2023
1 parent 0b9131c commit 8042015
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion graphenecommon/blockchainobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ def _store_item(self, key=None):
def _store_items(self, key=None):
key = key or self.__class__.__name__
if key in self._cache:
self._cache[key].extend(list(self))
# check for duplicates. race condition when loading might cause that store_items is called twice with same list
for x in list(self):
toadd = []
if x not in self._cache[key]:
toadd.append(x)
self._cache[key].extend(toadd)
else:
self._cache[key] = list(self)
self._fetched = True
Expand Down

0 comments on commit 8042015

Please sign in to comment.