From 72f104e44719dee90f27fb9b33c158a1eea4e2f2 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 4 May 2018 14:38:47 -0500 Subject: [PATCH] fixed crash in communicator --- onionr/communicator.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/onionr/communicator.py b/onionr/communicator.py index 0e0a1c77..feca37e6 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -512,6 +512,7 @@ class OnionrCommunicate: for i in self._core.getBlockList(unsaved=True).split("\n"): if i != "": if i in self.blocksProcessing or i in self.ignoredHashes: + logger.debug('already processing ' + i) continue else: self.blocksProcessing.append(i) @@ -568,15 +569,24 @@ class OnionrCommunicate: try: logger.info('Block type is ' + blockMetadata['type']) self._core.updateBlockInfo(i, 'dataType', blockMetadata['type']) - self.blocksProcessing.pop(i) + self.removeBlockFromProcessingList(i) + self.removeBlockFromProcessingList(i) except KeyError: logger.warn('Block has no type') pass except json.decoder.JSONDecodeError: logger.warn('Could not decode block metadata') - self.blocksProcessing.pop(i) + self.removeBlockFromProcessingList(i) return + def removeBlockFromProcessingList(self, block): + try: + self.blocksProcessing.remove(block) + except ValueError: + return False + else: + return True + def downloadBlock(self, hash, peerTries=3): ''' Download a block from random order of peers