Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Clear all history caches when block height changed #159

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading