progress removing communicator timers

master
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(
housekeeping.clean_old_blocks, self.shared_state, 20, 1)
housekeeping.clean_old_blocks, [self.shared_state], 20, 1)
# Timer to discover new peers
OnionrCommunicatorTimers(
self, lookupadders.lookup_new_peer_transports_with_communicator,
60, requires_peer=True, my_args=[shared_state], max_threads=2)
# Discover new peers
add_onionr_thread(
lookupadders.lookup_new_peer_transports_with_communicator,
[shared_state], 60, 3)
# Timer for adjusting which peers
# we actively communicate to at any given time,
# to avoid over-using peers
OnionrCommunicatorTimers(
self, cooldownpeer.cooldown_peer, 30,
my_args=[self], requires_peer=True)
add_onionr_thread(cooldownpeer.cooldown_peer, [self.shared_state], 30, 60)
# Timer to read the upload queue and upload the entries to peers
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."""
kv: "DeadSimpleKV" = comm_inst.shared_state.get_by_string("DeadSimpleKV")
config = comm_inst.config
kv: "DeadSimpleKV" = shared_state.get_by_string("DeadSimpleKV")
config = shared_state.get_by_string("OnionrCommunicatorDaemon").config
online_peer_amount = len(kv.get('onlinePeers'))
minTime = 300
cooldown_time = 600
@ -55,7 +55,6 @@ def cooldown_peer(comm_inst):
except ValueError:
break
else:
onlinepeers.remove_online_peer(comm_inst, to_cool)
onlinepeers.remove_online_peer(kv, to_cool)
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)
except ValueError:
pass
kv.get('newPeers').extend(newPeers)
shared_state.get_by_string("OnionrCommunicatorDaemon").decrementThreadCount('lookup_new_peer_transports_with_communicator')
kv.get('newPeers').extend(newPeers)

View File

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