fix: set is not a list
[electrum-server.git] / backends / bitcoind / blockchain_processor.py
index 5d83be4..32cc4f2 100644 (file)
@@ -266,14 +266,14 @@ class BlockchainProcessor(Processor):
         # sort history, because redeeming transactions are next to the corresponding txout
         hist.sort(key=lambda tup: tup[2])
 
-        # uniqueness
-        hist = set(map(lambda x: (x[0], x[2]), hist))
-
         # add memory pool
         with self.mempool_lock:
             for txid in self.mempool_hist.get(addr, []):
                 hist.append((txid, 0, 0))
 
+        # uniqueness
+        hist = set(map(lambda x: (x[0], x[2]), hist))
+
         # convert to dict
         hist = map(lambda x: {'tx_hash': x[0], 'height': x[1]}, hist)
 
@@ -852,8 +852,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:
@@ -861,8 +864,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)