fixed crash in communicator
This commit is contained in:
parent
ccea91e260
commit
72f104e447
@ -512,6 +512,7 @@ class OnionrCommunicate:
|
|||||||
for i in self._core.getBlockList(unsaved=True).split("\n"):
|
for i in self._core.getBlockList(unsaved=True).split("\n"):
|
||||||
if i != "":
|
if i != "":
|
||||||
if i in self.blocksProcessing or i in self.ignoredHashes:
|
if i in self.blocksProcessing or i in self.ignoredHashes:
|
||||||
|
logger.debug('already processing ' + i)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self.blocksProcessing.append(i)
|
self.blocksProcessing.append(i)
|
||||||
@ -568,15 +569,24 @@ class OnionrCommunicate:
|
|||||||
try:
|
try:
|
||||||
logger.info('Block type is ' + blockMetadata['type'])
|
logger.info('Block type is ' + blockMetadata['type'])
|
||||||
self._core.updateBlockInfo(i, 'dataType', blockMetadata['type'])
|
self._core.updateBlockInfo(i, 'dataType', blockMetadata['type'])
|
||||||
self.blocksProcessing.pop(i)
|
self.removeBlockFromProcessingList(i)
|
||||||
|
self.removeBlockFromProcessingList(i)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warn('Block has no type')
|
logger.warn('Block has no type')
|
||||||
pass
|
pass
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
logger.warn('Could not decode block metadata')
|
logger.warn('Could not decode block metadata')
|
||||||
self.blocksProcessing.pop(i)
|
self.removeBlockFromProcessingList(i)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def removeBlockFromProcessingList(self, block):
|
||||||
|
try:
|
||||||
|
self.blocksProcessing.remove(block)
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def downloadBlock(self, hash, peerTries=3):
|
def downloadBlock(self, hash, peerTries=3):
|
||||||
'''
|
'''
|
||||||
Download a block from random order of peers
|
Download a block from random order of peers
|
||||||
|
Loading…
Reference in New Issue
Block a user