From 4882a21b6a402c97d9d2cd2702f95b96e6f0945b Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 28 Jan 2019 16:49:04 -0600 Subject: [PATCH] improved uploading and fixed announce --- onionr/api.py | 7 ++++++- onionr/communicator.py | 3 +-- onionr/onionrdaemontools.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/onionr/api.py b/onionr/api.py index b0a6c8b6..f5ba9c81 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -436,4 +436,9 @@ class API: return False def getUptime(self): - return self._utils.getEpoch() - self.startTime \ No newline at end of file + while True: + try: + return self._utils.getEpoch - startTime + except AttributeError: + # Don't error on race condition with startup + pass \ No newline at end of file diff --git a/onionr/communicator.py b/onionr/communicator.py index 8ba63c32..1b8dc7fd 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -574,7 +574,7 @@ class OnionrCommunicatorDaemon: logger.warn('Requested to upload invalid block') self.decrementThreadCount('uploadBlock') return - for i in range(max(len(self.onlinePeers), 2)): + for i in range(min(len(self.onlinePeers), 6)): peer = self.pickOnlinePeer() if peer in triedPeers: continue @@ -590,7 +590,6 @@ class OnionrCommunicatorDaemon: if not self._core._utils.doPostRequest(url, data=data, proxyType=proxyType) == False: self._core._utils.localCommand('waitforshare/' + bl) finishedUploads.append(bl) - break for x in finishedUploads: try: self.blocksToUpload.remove(x) diff --git a/onionr/onionrdaemontools.py b/onionr/onionrdaemontools.py index 7e7c8ec7..faea0070 100644 --- a/onionr/onionrdaemontools.py +++ b/onionr/onionrdaemontools.py @@ -34,7 +34,7 @@ class DaemonTools: '''Announce our node to our peers''' retData = False announceFail = False - if self.daemon._core.config('general.security_level') == 0: + if self.daemon._core.config.get('general.security_level', 0) == 0: # Announce to random online peers for i in self.daemon.onlinePeers: if not i in self.announceCache: