From: ThomasV Date: Sat, 30 Mar 2013 17:06:18 +0000 (-0700) Subject: Merge pull request #24 from bjd/perf X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=commitdiff_plain;h=fe9f6ca863ee5f9a1d3ef6a9ef90e3e0b5badfd2;hp=24aa687775d6eac180088f72b2e8226cb572d7ef Merge pull request #24 from bjd/perf [perf] Fetch keys of mempool history maps outside of loop. --- diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 3f53dfb..398c110 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -736,8 +736,11 @@ class BlockchainProcessor(Processor): new_mempool_hist[addr] = h # invalidate cache for mempool addresses whose mempool history has changed - for addr in new_mempool_hist.keys(): - if addr in self.mempool_hist.keys(): + new_mempool_hist_keys = new_mempool_hist.keys() + self_mempool_hist_keys = self.mempool_hist.keys() + + for addr in new_mempool_hist_keys: + if addr in self_mempool_hist_keys: if self.mempool_hist[addr] != new_mempool_hist[addr]: self.invalidate_cache(addr) else: @@ -745,8 +748,8 @@ class BlockchainProcessor(Processor): # invalidate cache for addresses that are removed from mempool ? # this should not be necessary if they go into a block, but they might not - for addr in self.mempool_hist.keys(): - if addr not in new_mempool_hist.keys(): + for addr in self_mempool_hist_keys: + if addr not in new_mempool_hist_keys: self.invalidate_cache(addr)