+ added clear offline peers to new communicator

+ fixed unable to insert unencrypted block
master
Kevin Froman 2018-06-21 02:24:58 -05:00
parent 829dba45cc
commit 9968a72fbc
2 changed files with 11 additions and 2 deletions

View File

@ -63,6 +63,7 @@ class OnionrCommunicatorDaemon:
OnionrCommunicatorTimers(self, self.getOnlinePeers, 60) OnionrCommunicatorTimers(self, self.getOnlinePeers, 60)
OnionrCommunicatorTimers(self, self.lookupBlocks, 7) OnionrCommunicatorTimers(self, self.lookupBlocks, 7)
OnionrCommunicatorTimers(self, self.getBlocks, 10) OnionrCommunicatorTimers(self, self.getBlocks, 10)
OnionrCommunicatorTimers(self, self.clearOfflinePeer, 120)
#TODO: sync keys/peers #TODO: sync keys/peers
# Main daemon loop, mainly for calling timers, do not do any complex operations here # Main daemon loop, mainly for calling timers, do not do any complex operations here
@ -146,6 +147,14 @@ class OnionrCommunicatorDaemon:
self.threadCounts[threadName] -= 1 self.threadCounts[threadName] -= 1
except KeyError: except KeyError:
pass 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): def getOnlinePeers(self):
'''Manages the self.onlinePeers attribute list''' '''Manages the self.onlinePeers attribute list'''

View File

@ -683,10 +683,10 @@ class Core:
jsonMeta = json.dumps(meta) jsonMeta = json.dumps(meta)
if encryptType in ('asym', 'sym'): if encryptType in ('asym', 'sym', ''):
metadata['encryptType'] = encryptType metadata['encryptType'] = encryptType
else: 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 # sign before encrypt, as unauthenticated crypto should not be a problem here
if sign: if sign: