From 77fa5e9782c0df0a4b93349af8c5de768c454e86 Mon Sep 17 00:00:00 2001 From: Jeffrey Picard Date: Mon, 11 Apr 2022 00:50:33 +0000 Subject: [PATCH] cleanup code per pr comments --- lbry/testcase.py | 22 ++++++++++------------ lbry/wallet/network.py | 9 +-------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lbry/testcase.py b/lbry/testcase.py index f4a410292..aca0d7084 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -6,7 +6,6 @@ import logging import tempfile import functools import asyncio -import grpc from asyncio.runners import _cancel_all_tasks # type: ignore import unittest from unittest.case import _Outcome @@ -38,8 +37,6 @@ from lbry.extras.daemon.storage import SQLiteStorage from lbry.blob.blob_manager import BlobManager from lbry.stream.reflector.server import ReflectorServer from lbry.blob_exchange.server import BlobServer -from lbry.schema.types.v2 import hub_pb2_grpc -from lbry.schema.types.v2 import hub_pb2 class ColorHandler(logging.StreamHandler): @@ -346,18 +343,19 @@ class IntegrationTestCase(AsyncioTestCase): """ Ask lbrycrd to generate some blocks and wait until ledger has them. """ prepare = self.ledger.on_header.where(self.blockchain.is_expected_block) height = self.blockchain.block_expected - self.conductor.spv_node.server.es_synchronized.clear() - self.conductor.spv_node.server.go_hub_synchronized.clear() - self.conductor.spv_node.server.synchronized.clear() + server = self.conductor.spv_node.server + server.es_synchronized.clear() + server.go_hub_synchronized.clear() + server.synchronized.clear() await self.blockchain.generate(blocks) await prepare # no guarantee that it didn't happen already, so start waiting from before calling generate while True: - await self.conductor.spv_node.server.synchronized.wait() - self.conductor.spv_node.server.es_synchronized.clear() - self.conductor.spv_node.server.go_hub_synchronized.clear() - self.conductor.spv_node.server.synchronized.clear() - if self.conductor.spv_node.server.db.db_height >= height and \ - self.conductor.spv_node.server._go_hub_height == self.conductor.spv_node.server.db.db_height == self.conductor.spv_node.server._es_height: + await server.synchronized.wait() + server.es_synchronized.clear() + server.go_hub_synchronized.clear() + server.synchronized.clear() + if server.db.db_height >= height and \ + server._go_hub_height == server.db.db_height == server._es_height: break diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 7125bf01b..903fd1fda 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -10,8 +10,7 @@ from typing import Dict, Optional, Tuple import aiohttp import grpc from lbry.schema.types.v2 import hub_pb2_grpc -from lbry.schema.types.v2.hub_pb2 import SearchRequest -from lbry.schema.types.v2.hub_pb2 import StringArray +from lbry.schema.types.v2.hub_pb2 import SearchRequest, StringArray from lbry import __version__ from lbry.utils import resolve_host @@ -479,12 +478,6 @@ class Network: def claim_search(self, session_override=None, **kwargs): return self.rpc('blockchain.claimtrie.search', kwargs, False, session_override) - async def new_resolve(self, server, urls): - message = {"method": "resolve", "params": {"urls": urls, "protobuf": True}} - async with self.aiohttp_session.post(server, json=message) as r: - result = await r.json() - return result['result'] - async def new_claim_search(self, server, **kwargs): async with grpc.aio.insecure_channel(server) as channel: stub = hub_pb2_grpc.HubStub(channel)