X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Fbitcoind%2Fblockchain_processor.py;h=73fe481bb907daa78f5db075f635a641cdd6a780;hb=2d47ce381274578dfa52c6042bb7e0c433518fbf;hp=78ef690bf43747404c04a836602a0845769407b5;hpb=fcf7076e578cffcd672a6bcf23d0459fc076fef5;p=electrum-server.git diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 78ef690..73fe481 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -111,7 +111,7 @@ class BlockchainProcessor(Processor): shared.stop() sys.exit(0) - print "blockchain is up to date." + print_log( "blockchain is up to date." ) threading.Timer(10, self.main_iteration).start() @@ -449,7 +449,7 @@ class BlockchainProcessor(Processor): self.db.Write(batch, sync = sync) t3 = time.time() - if t3 - t0 > 10: + if t3 - t0 > 10 and not sync: print_log("block", block_height, "parse:%0.2f "%(t00 - t0), "read:%0.2f "%(t1 - t00), @@ -669,16 +669,23 @@ class BlockchainProcessor(Processor): self.mempool_addresses.pop(tx_hash) # rebuild histories - with self.mempool_lock: - self.mempool_hist = {} - for tx_hash, addresses in self.mempool_addresses.items(): - for addr in addresses: - h = self.mempool_hist.get(addr, []) - if tx_hash not in h: - h.append( tx_hash ) - self.mempool_hist[addr] = h - self.invalidate_cache(addr) + new_mempool_hist = {} + for tx_hash, addresses in self.mempool_addresses.items(): + for addr in addresses: + h = new_mempool_hist.get(addr, []) + if tx_hash not in h: + h.append( tx_hash ) + new_mempool_hist[addr] = h + + 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: + self.invalidate_cache(addr) + with self.mempool_lock: + self.mempool_hist = new_mempool_hist @@ -688,6 +695,9 @@ class BlockchainProcessor(Processor): print_log( "cache: invalidating", address ) self.history_cache.pop(address) + if address in self.watched_addresses: + self.address_queue.put(address) + def main_iteration(self): @@ -703,7 +713,7 @@ class BlockchainProcessor(Processor): self.memorypool_update() t3 = time.time() - print "mempool:", len(self.mempool_addresses), len(self.mempool_hist), "%.3fs"%(t3 - t2) + # print "mempool:", len(self.mempool_addresses), len(self.mempool_hist), "%.3fs"%(t3 - t2) if self.sent_height != self.height: @@ -723,6 +733,7 @@ class BlockchainProcessor(Processor): if addr in self.watched_addresses: status = self.get_status( addr ) self.push_response({ 'id': None, 'method':'blockchain.address.subscribe', 'params':[addr, status] }) + self.push_response({ 'id': None, 'method':'blockchain.address.subscribe2', 'params':[addr, status] }) if not self.shared.stopped():