From 42e82bf3092c09062fdda2c0f56704d82ca9412d Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 27 Mar 2024 21:36:47 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Clear=20all=20history=20ca?= =?UTF-8?q?ches=20when=20block=20height=20changed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electrumx/server/session.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/electrumx/server/session.py b/electrumx/server/session.py index 56119d84..b04084e9 100644 --- a/electrumx/server/session.py +++ b/electrumx/server/session.py @@ -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}")