diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index d40db5698..212411188 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -4150,7 +4150,7 @@ class Daemon(metaclass=JSONRPCServerType): wallet = self.wallet_manager.get_wallet_or_default(wallet_id) if claim_id: - txo = await self.ledger.get_claim_by_claim_id(wallet.accounts, claim_id) + txo = await self.ledger.get_claim_by_claim_id(claim_id, wallet.accounts) if not isinstance(txo, Output) or not txo.is_claim: # TODO: use error from lbry.error raise Exception(f"Could not find collection with claim_id '{claim_id}'.") diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index d671b1e2a..9583c22a7 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -556,7 +556,7 @@ class Ledger(metaclass=LedgerRegistry): log.info("Sync finished for address %s: %d/%d", address, len(pending_synced_history), len(to_request)) assert len(pending_synced_history) == len(remote_history), \ - f"{len(pending_synced_history)} vs {len(remote_history)}" + f"{len(pending_synced_history)} vs {len(remote_history)} for {address}" 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}" diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 0898d7e67..5f796bef5 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -238,7 +238,7 @@ class Network: log.exception("error looking up dns for spv server %s:%i", server, port) # accumulate the dns results - if self.config['explicit_servers']: + if self.config.get('explicit_servers', []): hubs = self.config['explicit_servers'] elif self.known_hubs: hubs = self.known_hubs @@ -254,7 +254,7 @@ class Network: sent_ping_timestamps = {} _, ip_to_hostnames = await self.resolve_spv_dns() n = len(ip_to_hostnames) - log.info("%i possible spv servers to try (%i urls in config)", n, len(self.config['explicit_servers'])) + log.info("%i possible spv servers to try (%i urls in config)", n, len(self.config.get('explicit_servers', []))) pongs = {} known_hubs = self.known_hubs try: @@ -299,8 +299,8 @@ class Network: if (pong is not None and self.jurisdiction is not None) and \ (pong.country_name != self.jurisdiction): continue - client = ClientSession(network=self, server=(host, port), timeout=self.config['hub_timeout'], - concurrency=self.config['concurrent_hub_requests']) + client = ClientSession(network=self, server=(host, port), timeout=self.config.get('hub_timeout', 30), + concurrency=self.config.get('concurrent_hub_requests', 30)) try: await client.create_connection() log.warning("Connected to spv server %s:%i", host, port) diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index d31e81eea..4132e8c33 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -660,7 +660,7 @@ class LevelDB: def get_counts(): return tuple( Prefixes.tx_count.unpack_value(packed_tx_count).tx_count - for packed_tx_count in self.db.iterator(prefix=Prefixes.tx_count.value, include_key=False) + for packed_tx_count in self.db.iterator(prefix=Prefixes.tx_count.prefix, include_key=False) ) tx_counts = await asyncio.get_event_loop().run_in_executor(self.executor, get_counts) @@ -1083,8 +1083,12 @@ class LevelDB: utxos = [] utxo_append = utxos.append for (tx_hash, nout) in prevouts: + if tx_hash not in self.transaction_num_mapping: + continue tx_num = self.transaction_num_mapping[tx_hash] hashX = self.db.get(Prefixes.hashX_utxo.pack_key(tx_hash[:4], tx_num, nout)) + if not hashX: + continue utxo_value = self.db.get(Prefixes.utxo.pack_key(hashX, tx_num, nout)) if utxo_value: utxo_append((hashX, Prefixes.utxo.unpack_value(utxo_value).amount)) diff --git a/tests/integration/blockchain/test_network.py b/tests/integration/blockchain/test_network.py index 25092d6f5..3f757f14b 100644 --- a/tests/integration/blockchain/test_network.py +++ b/tests/integration/blockchain/test_network.py @@ -178,7 +178,7 @@ class UDPServerFailDiscoveryTest(AsyncioTestCase): class ServerPickingTestCase(AsyncioTestCase): async def _make_udp_server(self, port, latency) -> StatusServer: s = StatusServer() - await s.start(0, b'\x00' * 32, '127.0.0.1', port) + await s.start(0, b'\x00' * 32, 'US', '127.0.0.1', port, True) s.set_available() sendto = s._protocol.transport.sendto