From f9cc21807f0976672b25a2227ecf7c5a3f061b46 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 27 Nov 2016 07:58:13 +0900 Subject: [PATCH] Further optimize the inner loop --- server/block_processor.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/server/block_processor.py b/server/block_processor.py index c3f16aa..1e661ac 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -224,6 +224,7 @@ class BlockProcessor(server.db.DB): if self.caught_up: # Flush everything as queries are performed on the DB and # not in-memory. + await asyncio.sleep(0) self.flush(True) self.client.notify(touched) elif time.time() > self.next_cache_check: @@ -498,43 +499,47 @@ class BlockProcessor(server.db.DB): self.write_undo_info(self.height, b''.join(undo_info)) def advance_txs(self, tx_hashes, txs, touched): - put_utxo = self.utxo_cache.__setitem__ - spend_utxo = self.spend_utxo undo_info = [] # Use local vars for speed in the loops history = self.history + history_size = self.history_size tx_num = self.tx_count script_hash168 = self.coin.hash168_from_script() s_pack = pack + put_utxo = self.utxo_cache.__setitem__ + spend_utxo = self.spend_utxo + undo_info_append = undo_info.append for tx, tx_hash in zip(txs, tx_hashes): hash168s = set() + add_hash168 = hash168s.add tx_numb = s_pack('