Skip to content

Commit

Permalink
pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrobison committed Jul 15, 2020
1 parent 80535a9 commit 097f782
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lbry/wallet/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time
import asyncio
import logging
from io import StringIO
from datetime import datetime
from functools import partial
from operator import itemgetter
Expand Down Expand Up @@ -490,7 +489,8 @@ def process_status_update(self, update):
address, remote_status = update
self._update_tasks.add(self.update_history(address, remote_status))

async def update_history(self, address, remote_status, address_manager: AddressManager = None, reattempt_update: bool = True):
async def update_history(self, address, remote_status, address_manager: AddressManager = None,
reattempt_update: bool = True):
async with self._address_update_locks[address]:
self._known_addresses_out_of_sync.discard(address)
local_status, local_history = await self.get_local_status_and_history(address)
Expand Down Expand Up @@ -557,19 +557,23 @@ async def update_history(self, address, remote_status, address_manager: AddressM
# continue
to_request[i] = (txid, remote_height)

log.debug("request %i transactions, %i/%i for %s are already synced", len(to_request), len(synced_txs), len(remote_history), address)
log.debug(
"request %i transactions, %i/%i for %s are already synced", len(to_request), len(synced_txs),
len(remote_history), address
)
requested_txes = await self._request_transaction_batch(to_request, len(remote_history), address)
for tx in requested_txes:
pending_synced_history[tx_indexes[tx.id]] = f"{tx.id}:{tx.height}:"
synced_txs.append(tx)

assert len(pending_synced_history) == len(remote_history), f"{len(pending_synced_history)} vs {len(remote_history)}\n{remote_history}\n{pending_synced_history}"
assert len(pending_synced_history) == len(remote_history), \
f"{len(pending_synced_history)} vs {len(remote_history)}"
synced_history = ""
for remote_i, i in zip(range(len(remote_history)), sorted(pending_synced_history.keys())):
assert i == remote_i, f"{i} vs {remote_i}"
txid, height = remote_history[remote_i]
if f"{txid}:{height}:" != pending_synced_history[i]:
log.warning("history mismatch: %s:%i: vs %s", remote_history[remote_i], pending_synced_history[i])
log.warning("history mismatch: %s vs %s", remote_history[remote_i], pending_synced_history[i])
synced_history += pending_synced_history[i]

cache_size = self.config.get("tx_cache_size", 100_000)
Expand All @@ -582,7 +586,6 @@ async def update_history(self, address, remote_status, address_manager: AddressM
cache_item.lock.release()
except RuntimeError:
log.warning("lock was already released?")
pass

await self.db.save_transaction_io_batch(
[], address, self.address_to_hash160(address), synced_history
Expand Down Expand Up @@ -724,7 +727,7 @@ async def _single_batch(batch):
try:
header = header_cache.get(remote_heights[txid]) or (await self.headers.get(merkle_height))
except IndexError:
log.warning("failed to verify %s at height %i", tx.id, merkle_height)
log.warning("failed to verify %s at height %i", tx.id, merkle_height)
else:
header_cache[remote_heights[txid]] = header
tx.position = merkle['pos']
Expand Down

0 comments on commit 097f782

Please sign in to comment.