From 0e9da24d79d295602206efaaff3a0d962357e979 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 11 Aug 2019 15:44:16 -0500 Subject: [PATCH] refactored lookup timer calls in communicator --- onionr/communicator/__init__.py | 12 ++---------- onionr/communicatorutils/lookupadders.py | 2 +- onionr/communicatorutils/lookupblocks.py | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/onionr/communicator/__init__.py b/onionr/communicator/__init__.py index 3b9ee646..95cb9c45 100755 --- a/onionr/communicator/__init__.py +++ b/onionr/communicator/__init__.py @@ -102,7 +102,7 @@ class OnionrCommunicatorDaemon: OnionrCommunicatorTimers(self, self.runCheck, 2, maxThreads=1) # Timers to periodically lookup new blocks and download them - OnionrCommunicatorTimers(self, self.lookupBlocks, config.get('timers.lookupBlocks', 25), requiresPeer=True, maxThreads=1) + OnionrCommunicatorTimers(self, lookupblocks.lookup_blocks_from_communicator, config.get('timers.lookupBlocks', 25), myArgs=[self], requiresPeer=True, maxThreads=1) OnionrCommunicatorTimers(self, self.getBlocks, config.get('timers.getBlocks', 30), requiresPeer=True, maxThreads=2) # Timer to reset the longest offline peer so contact can be attempted again @@ -112,7 +112,7 @@ class OnionrCommunicatorDaemon: blockCleanupTimer = OnionrCommunicatorTimers(self, housekeeping.clean_old_blocks, 65, myArgs=[self]) # Timer to discover new peers - OnionrCommunicatorTimers(self, self.lookupAdders, 60, requiresPeer=True) + OnionrCommunicatorTimers(self, lookupadders.lookup_new_peer_transports_with_communicator, 60, requiresPeer=True, myArgs=[self], maxThreads=2) # Timer for adjusting which peers we actively communicate to at any given time, to avoid over-using peers OnionrCommunicatorTimers(self, cooldownpeer.cooldown_peer, 30, myArgs=[self], requiresPeer=True) @@ -190,14 +190,6 @@ class OnionrCommunicatorDaemon: except KeyboardInterrupt: pass - def lookupAdders(self): - '''Lookup new peer addresses''' - lookupadders.lookup_new_peer_transports_with_communicator(self) - - def lookupBlocks(self): - '''Lookup new blocks & add them to download queue''' - lookupblocks.lookup_blocks_from_communicator(self) - def getBlocks(self): '''download new blocks in queue''' downloadblocks.download_blocks_from_communicator(self) diff --git a/onionr/communicatorutils/lookupadders.py b/onionr/communicatorutils/lookupadders.py index 7d591e79..9eed48bd 100755 --- a/onionr/communicatorutils/lookupadders.py +++ b/onionr/communicatorutils/lookupadders.py @@ -49,4 +49,4 @@ def lookup_new_peer_transports_with_communicator(comm_inst): for x in invalid: newPeers.remove(x) comm_inst.newPeers.extend(newPeers) - comm_inst.decrementThreadCount('lookupAdders') \ No newline at end of file + comm_inst.decrementThreadCount('lookup_new_peer_transports_with_communicator') \ No newline at end of file diff --git a/onionr/communicatorutils/lookupblocks.py b/onionr/communicatorutils/lookupblocks.py index 176422b4..3f15fd9d 100755 --- a/onionr/communicatorutils/lookupblocks.py +++ b/onionr/communicatorutils/lookupblocks.py @@ -89,5 +89,5 @@ def lookup_blocks_from_communicator(comm_inst): if new_block_count > 1: block_string = "s" logger.info('Discovered %s new block%s' % (new_block_count, block_string), terminal=True) - comm_inst.decrementThreadCount('lookupBlocks') + comm_inst.decrementThreadCount('lookup_blocks_from_communicator') return \ No newline at end of file