From 9968a72fbca004ef7e3aadefbdf893be431d1f31 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 21 Jun 2018 02:24:58 -0500 Subject: [PATCH] + added clear offline peers to new communicator + fixed unable to insert unencrypted block --- onionr/communicator2.py | 9 +++++++++ onionr/core.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/onionr/communicator2.py b/onionr/communicator2.py index eff289ed..33b23c2f 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -63,6 +63,7 @@ class OnionrCommunicatorDaemon: OnionrCommunicatorTimers(self, self.getOnlinePeers, 60) OnionrCommunicatorTimers(self, self.lookupBlocks, 7) OnionrCommunicatorTimers(self, self.getBlocks, 10) + OnionrCommunicatorTimers(self, self.clearOfflinePeer, 120) #TODO: sync keys/peers # Main daemon loop, mainly for calling timers, do not do any complex operations here @@ -146,6 +147,14 @@ class OnionrCommunicatorDaemon: self.threadCounts[threadName] -= 1 except KeyError: pass + + def clearOfflinePeer(self): + '''Removes the longest offline peer to retry later''' + try: + self.offlinePeers.pop(0) + except IndexError: + pass + self.decrementThreadCount('clearOfflinePeer') def getOnlinePeers(self): '''Manages the self.onlinePeers attribute list''' diff --git a/onionr/core.py b/onionr/core.py index 1d0cc6b7..78186089 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -683,10 +683,10 @@ class Core: jsonMeta = json.dumps(meta) - if encryptType in ('asym', 'sym'): + if encryptType in ('asym', 'sym', ''): metadata['encryptType'] = encryptType else: - raise onionrexceptions.InvalidMetadata('encryptType must be asym or sym') + raise onionrexceptions.InvalidMetadata('encryptType must be asym or sym, or blank') # sign before encrypt, as unauthenticated crypto should not be a problem here if sign: