Remove invalidated history cache on notifications
This commit is contained in:
parent
643c990684
commit
1f1f0f42f8
@ -15,7 +15,7 @@ import ssl
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
from functools import partial, lru_cache
|
from functools import partial
|
||||||
|
|
||||||
import pylru
|
import pylru
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ class ServerManager(util.LoggedClass):
|
|||||||
self.max_subs = env.max_subs
|
self.max_subs = env.max_subs
|
||||||
self.subscription_count = 0
|
self.subscription_count = 0
|
||||||
self.next_stale_check = 0
|
self.next_stale_check = 0
|
||||||
self.history_cache = pylru.lrucache(512)
|
self.history_cache = pylru.lrucache(128)
|
||||||
self.futures = []
|
self.futures = []
|
||||||
env.max_send = max(350000, env.max_send)
|
env.max_send = max(350000, env.max_send)
|
||||||
self.logger.info('session timeout: {:,d} seconds'
|
self.logger.info('session timeout: {:,d} seconds'
|
||||||
@ -318,6 +318,10 @@ class ServerManager(util.LoggedClass):
|
|||||||
|
|
||||||
def notify(self, touched):
|
def notify(self, touched):
|
||||||
'''Notify sessions about height changes and touched addresses.'''
|
'''Notify sessions about height changes and touched addresses.'''
|
||||||
|
# Remove invalidated history cache
|
||||||
|
hc = self.history_cache
|
||||||
|
for hash168 in set(hc).intersection(touched):
|
||||||
|
del hc[hash168]
|
||||||
cache = {}
|
cache = {}
|
||||||
for session in self.sessions:
|
for session in self.sessions:
|
||||||
if isinstance(session, ElectrumX):
|
if isinstance(session, ElectrumX):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user