transaction_num_mapping

This commit is contained in:
Jack Robison 2021-02-19 13:22:07 -05:00 committed by Victor Shyba
parent ef3bab16d3
commit 0a833f5f83
2 changed files with 5 additions and 1 deletions

View file

@ -544,7 +544,7 @@ class BlockProcessor:
self.utxo_cache[txin.prev_hash + s_pack('<H', txin.prev_idx)] = undo_item self.utxo_cache[txin.prev_hash + s_pack('<H', txin.prev_idx)] = undo_item
self.touched.add(undo_item[:-12]) self.touched.add(undo_item[:-12])
self.db.total_transactions.pop() self.db.transaction_num_mapping.pop(self.db.total_transactions.pop())
assert n == 0 assert n == 0
self.tx_count -= len(txs) self.tx_count -= len(txs)

View file

@ -111,6 +111,7 @@ class LevelDB:
self._tx_and_merkle_cache = LRUCacheWithMetrics(2 ** 17, metric_name='tx_and_merkle', namespace="wallet_server") self._tx_and_merkle_cache = LRUCacheWithMetrics(2 ** 17, metric_name='tx_and_merkle', namespace="wallet_server")
self.total_transactions = None self.total_transactions = None
self.transaction_num_mapping = {}
# def add_unflushed(self, hashXs_by_tx, first_tx_num): # def add_unflushed(self, hashXs_by_tx, first_tx_num):
# unflushed = self.history.unflushed # unflushed = self.history.unflushed
@ -156,6 +157,9 @@ class LevelDB:
txids = await asyncio.get_event_loop().run_in_executor(self.executor, get_txids) txids = await asyncio.get_event_loop().run_in_executor(self.executor, get_txids)
assert len(txids) == len(self.tx_counts) == 0 or len(txids) == self.tx_counts[-1] assert len(txids) == len(self.tx_counts) == 0 or len(txids) == self.tx_counts[-1]
self.total_transactions = txids self.total_transactions = txids
self.transaction_num_mapping = {
txid: i for i, txid in enumerate(txids)
}
ts = time.perf_counter() - start ts = time.perf_counter() - start
self.logger.info("loaded %i txids in %ss", len(self.total_transactions), round(ts, 4)) self.logger.info("loaded %i txids in %ss", len(self.total_transactions), round(ts, 4))