From aef6d5d8e640783e50be5e83a17603ac76ac6a22 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 21 Jan 2019 21:29:29 -0600 Subject: [PATCH] bug fixes and performence improvements --- onionr/communicator2.py | 5 ++++- onionr/static-data/default-plugins/pms/main.py | 17 +++++++++++------ onionr/static-data/default_config.json | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/onionr/communicator2.py b/onionr/communicator2.py index d131e332..632142d4 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -218,7 +218,8 @@ class OnionrCommunicatorDaemon: # if block does not exist on disk and is not already in block queue if i not in self.blockQueue and not self._core._blacklist.inBlacklist(i): if onionrproofs.hashMeetsDifficulty(i): - self.blockQueue.append(i) # add blocks to download queue + if len(self.blockQueue) <= 1000000: + self.blockQueue.append(i) # add blocks to download queue self.decrementThreadCount('lookupBlocks') return @@ -295,6 +296,8 @@ class OnionrCommunicatorDaemon: if tempHash != 'ed55e34cb828232d6c14da0479709bfa10a0923dca2b380496e6b2ed4f7a0253': # Dumb hack for 404 response from peer. Don't log it if 404 since its likely not malicious or a critical error. logger.warn('Block hash validation failed for ' + blockHash + ' got ' + tempHash) + else: + removeFromQueue = False # Don't remove from queue if 404 if removeFromQueue: try: self.blockQueue.remove(blockHash) # remove from block queue both if success or false diff --git a/onionr/static-data/default-plugins/pms/main.py b/onionr/static-data/default-plugins/pms/main.py index 0cf7e2eb..01e078b2 100644 --- a/onionr/static-data/default-plugins/pms/main.py +++ b/onionr/static-data/default-plugins/pms/main.py @@ -207,22 +207,27 @@ class OnionrMail: else: # if -q or ctrl-c/d, exit function here, otherwise we successfully got the public key return - - logger.info('Enter your message, stop by entering -q on a new line.') + + cancelEnter = False + logger.info('Enter your message, stop by entering -q on a new line. -c to cancel') while newLine != '-q': try: newLine = input() except (KeyboardInterrupt, EOFError): - pass + cancelEnter = True + if newLine == '-c': + cancelEnter = True + break if newLine == '-q': continue newLine += '\n' message += newLine - logger.info('Inserting encrypted message as Onionr block....') + if not cancelEnter: + logger.info('Inserting encrypted message as Onionr block....') - blockID = self.myCore.insertBlock(message, header='pm', encryptType='asym', asymPeer=recip, sign=True) - self.sentboxTools.addToSent(blockID, recip, message) + blockID = self.myCore.insertBlock(message, header='pm', encryptType='asym', asymPeer=recip, sign=True) + self.sentboxTools.addToSent(blockID, recip, message) def menu(self): choice = '' while True: diff --git a/onionr/static-data/default_config.json b/onionr/static-data/default_config.json index 5080ac5d..b6cb3145 100644 --- a/onionr/static-data/default_config.json +++ b/onionr/static-data/default_config.json @@ -79,7 +79,7 @@ "peers" : { "minimum_score" : -100, "max_stored_peers" : 5000, - "max_connect" : 50 + "max_connect" : 1000 }, "timers" : {