Remove unnecessary use of comprehension

Signed-off-by: shubhendra <withshubh@gmail.com>
This commit is contained in:
shubhendra 2021-03-26 18:45:38 +05:30 committed by Lex Berezhny
parent be0ba22222
commit 4725f510d8
3 changed files with 3 additions and 6 deletions

View file

@ -605,8 +605,7 @@ class BlockProcessor:
# Key: b'h' + compressed_tx_hash + tx_idx + tx_num # Key: b'h' + compressed_tx_hash + tx_idx + tx_num
# Value: hashX # Value: hashX
prefix = b'h' + tx_hash[:4] + idx_packed prefix = b'h' + tx_hash[:4] + idx_packed
candidates = {db_key: hashX for db_key, hashX candidates = dict(self.db.utxo_db.iterator(prefix=prefix))
in self.db.utxo_db.iterator(prefix=prefix)}
for hdb_key, hashX in candidates.items(): for hdb_key, hashX in candidates.items():
tx_num_packed = hdb_key[-4:] tx_num_packed = hdb_key[-4:]
if len(candidates) > 1: if len(candidates) > 1:

View file

@ -137,9 +137,7 @@ class LevelDB:
return return
def get_headers(): def get_headers():
return [ return list(self.headers_db.iterator(prefix=HEADER_PREFIX, include_key=False))
header for header in self.headers_db.iterator(prefix=HEADER_PREFIX, include_key=False)
]
headers = await asyncio.get_event_loop().run_in_executor(self.executor, get_headers) headers = await asyncio.get_event_loop().run_in_executor(self.executor, get_headers)
assert len(headers) - 1 == self.db_height, f"{len(headers)} vs {self.db_height}" assert len(headers) - 1 == self.db_height, f"{len(headers)} vs {self.db_height}"

View file

@ -324,7 +324,7 @@ class MemPool:
for prevout in tx.prevouts for prevout in tx.prevouts
if prevout[0] not in all_hashes) if prevout[0] not in all_hashes)
utxos = await self.api.lookup_utxos(prevouts) utxos = await self.api.lookup_utxos(prevouts)
utxo_map = {prevout: utxo for prevout, utxo in zip(prevouts, utxos)} utxo_map = dict(zip(prevouts, utxos))
return self._accept_transactions(tx_map, utxo_map, touched) return self._accept_transactions(tx_map, utxo_map, touched)