From 6f06026511dba886672f1d1df0fcfc74931469f1 Mon Sep 17 00:00:00 2001 From: Victor Shyba <victor1984@riseup.net> Date: Sun, 12 May 2019 00:52:46 -0300 Subject: [PATCH] announcer goes idle if no peers in routing table --- lbrynet/dht/blob_announcer.py | 5 ++++- lbrynet/dht/node.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lbrynet/dht/blob_announcer.py b/lbrynet/dht/blob_announcer.py index 33ab4f70e..9321b8536 100644 --- a/lbrynet/dht/blob_announcer.py +++ b/lbrynet/dht/blob_announcer.py @@ -33,6 +33,10 @@ class BlobAnnouncer: while batch_size: if not self.node.joined.is_set(): await self.node.joined.wait() + await asyncio.sleep(60) + if not self.node.protocol.routing_table.get_peers(): + log.warning("No peers in DHT, announce round skipped") + continue self.announce_queue.extend(await self.storage.get_blobs_to_announce()) log.debug("announcer task wake up, %d blobs to announce", len(self.announce_queue)) while len(self.announce_queue): @@ -45,7 +49,6 @@ class BlobAnnouncer: if announced: await self.storage.update_last_announced_blobs(announced) log.info("announced %i blobs", len(announced)) - await asyncio.sleep(60) def start(self, batch_size: typing.Optional[int] = 10): assert not self.announce_task or self.announce_task.done(), "already running" diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index aa52a9067..1efe78037 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -91,7 +91,7 @@ class Node: log.info("Stored %s to %i of %i attempted peers", binascii.hexlify(hash_value).decode()[:8], len(stored_to), len(peers)) else: - log.warning("Failed announcing %s, stored to 0 peers") + log.warning("Failed announcing %s, stored to 0 peers", blob_hash[:8]) return stored_to def stop(self) -> None: