X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=blobdiff_plain;f=backends%2Fbitcoind%2Fblockchain_processor.py;h=ef417931a1c0e26bdda4ebcea2b5d4e2a449fc53;hp=5e7901ae705c022fb9ecaa2b810ab54ba4cd35ce;hb=ea4579674d6e742bfd7f533f2aa62fc2e677f780;hpb=9dc7d29da08206a6a576714770431e0fc895d356 diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 5e7901a..ef41793 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -182,6 +182,11 @@ class BlockchainProcessor(Processor): if sync or len(self.headers_data) > 40*100: self.flush_headers() + with self.cache_lock: + chunk_index = header.get('block_height')/2016 + if self.chunk_cache.get(chunk_index): + self.chunk_cache.pop(chunk_index) + def pop_header(self): # we need to do this only if we have not flushed if self.headers_data: @@ -198,10 +203,12 @@ class BlockchainProcessor(Processor): def get_chunk(self, i): # store them on disk; store the current chunk in memory - chunk = self.chunk_cache.get(i) - if not chunk: - chunk = self.read_chunk(i) - self.chunk_cache[i] = chunk + with self.cache_lock: + chunk = self.chunk_cache.get(i) + if not chunk: + chunk = self.read_chunk(i) + self.chunk_cache[i] = chunk + return chunk