Skip to content

Commit

Permalink
Merge pull request #159 from AlexV525/fix/history-cache
Browse files Browse the repository at this point in the history
⚡️ Clear all history caches when block height changed
  • Loading branch information
atomicals authored Mar 27, 2024
2 parents 87eb9fa + 42e82bf commit 47dae8b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions electrumx/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,11 +1046,10 @@ async def _notify_sessions(self, height, touched):
height_changed = height != self.notified_height
if height_changed:
await self._refresh_hsub_results(height)
# Invalidate our history cache for touched hashXs
cache = self._history_cache
# Invalidate all history caches since they rely on block heights
self._history_cache.clear()
# Invalidate our op cache for touched hashXs
op_cache = self._history_op_cache
for hashX in set(cache).intersection(touched):
del cache[hashX]
for hashX in set(op_cache).intersection(touched):
op_cache.pop(hashX, None)
self.logger.info(f"refresh op cache {self.notified_height}")
Expand Down

0 comments on commit 47dae8b

Please sign in to comment.