progress removing communicator timers

This commit is contained in:
Kevin Froman 2020-11-15 18:52:52 +00:00
parent ecd2cc54da
commit cc703fc404
4 changed files with 14 additions and 17 deletions

View File

@ -98,19 +98,17 @@ class OnionrCommunicatorDaemon:
add_onionr_thread(onlinepeers.clear_offline_peer, [self.kv], 58) add_onionr_thread(onlinepeers.clear_offline_peer, [self.kv], 58)
add_onionr_thread( add_onionr_thread(
housekeeping.clean_old_blocks, self.shared_state, 20, 1) housekeeping.clean_old_blocks, [self.shared_state], 20, 1)
# Timer to discover new peers # Discover new peers
OnionrCommunicatorTimers( add_onionr_thread(
self, lookupadders.lookup_new_peer_transports_with_communicator, lookupadders.lookup_new_peer_transports_with_communicator,
60, requires_peer=True, my_args=[shared_state], max_threads=2) [shared_state], 60, 3)
# Timer for adjusting which peers # Timer for adjusting which peers
# we actively communicate to at any given time, # we actively communicate to at any given time,
# to avoid over-using peers # to avoid over-using peers
OnionrCommunicatorTimers( add_onionr_thread(cooldownpeer.cooldown_peer, [self.shared_state], 30, 60)
self, cooldownpeer.cooldown_peer, 30,
my_args=[self], requires_peer=True)
# Timer to read the upload queue and upload the entries to peers # Timer to read the upload queue and upload the entries to peers
OnionrCommunicatorTimers( OnionrCommunicatorTimers(

View File

@ -25,10 +25,10 @@ if TYPE_CHECKING:
""" """
def cooldown_peer(comm_inst): def cooldown_peer(shared_state):
"""Randomly add an online peer to cooldown, so we can connect a new one.""" """Randomly add an online peer to cooldown, so we can connect a new one."""
kv: "DeadSimpleKV" = comm_inst.shared_state.get_by_string("DeadSimpleKV") kv: "DeadSimpleKV" = shared_state.get_by_string("DeadSimpleKV")
config = comm_inst.config config = shared_state.get_by_string("OnionrCommunicatorDaemon").config
online_peer_amount = len(kv.get('onlinePeers')) online_peer_amount = len(kv.get('onlinePeers'))
minTime = 300 minTime = 300
cooldown_time = 600 cooldown_time = 600
@ -55,7 +55,6 @@ def cooldown_peer(comm_inst):
except ValueError: except ValueError:
break break
else: else:
onlinepeers.remove_online_peer(comm_inst, to_cool) onlinepeers.remove_online_peer(kv, to_cool)
kv.get('cooldownPeer')[to_cool] = epoch.get_epoch() kv.get('cooldownPeer')[to_cool] = epoch.get_epoch()
comm_inst.decrementThreadCount('cooldown_peer')

View File

@ -63,5 +63,4 @@ def lookup_new_peer_transports_with_communicator(shared_state):
newPeers.remove(x) newPeers.remove(x)
except ValueError: except ValueError:
pass pass
kv.get('newPeers').extend(newPeers) kv.get('newPeers').extend(newPeers)
shared_state.get_by_string("OnionrCommunicatorDaemon").decrementThreadCount('lookup_new_peer_transports_with_communicator')

View File

@ -45,9 +45,10 @@ class _Importer(FileSystemEventHandler):
os.remove(event.src_path) os.remove(event.src_path)
try: try:
import_block_from_data(block_data) import_block_from_data(block_data)
except( except( # noqa
onionrexceptions.DataExists, onionrexceptions.DataExists,
onionrexceptions.BlockMetaEntryExists) as _: onionrexceptions.BlockMetaEntryExists,
onionrexceptions.InvalidMetadata) as _:
return return
if block_data_location in event.src_path: if block_data_location in event.src_path:
try: try: