fixed wrong var used for peer causing crash

master
Kevin Froman 2018-04-25 18:21:43 -05:00
parent c249a42bb7
commit acd5494979
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 9 additions and 4 deletions

View File

@ -83,7 +83,7 @@ class OnionrCommunicate:
if highFailureTimer == highFailureRate:
highFailureTimer = 0
for i in self.peerData:
if self.peerData[i]['failCount'] == self.highFailureAmount:
if self.peerData[i]['failCount'] >= self.highFailureAmount:
self.peerData[i]['failCount'] -= 1
if pexTimer == pexCount:
self.getNewPeers()
@ -204,7 +204,7 @@ class OnionrCommunicate:
blocks += self.performGet('getBlockHashes', i)
except TypeError:
logger.warn('Failed to get data hash from ' + i)
self.peerData[peer]['failCount'] -= 1
self.peerData[i]['failCount'] -= 1
if self._utils.validateHash(currentDB):
self._core.setAddressInfo(i, "DBHash", currentDB)
if len(blocks.strip()) != 0:

View File

@ -595,6 +595,11 @@ class Core:
'''
retData = ''
metadata = '-' + header + '-'
metadata = metadata.encode()
try:
data.decode()
except AttributeError:
data = data.encode()
if len(data) == 0:
logger.error('Will not insert empty block')
else:

View File

@ -572,13 +572,13 @@ class Onionr:
newFile = sys.argv[2]
logger.info('Attempting to add file...')
try:
with open(newFile, 'r') as new:
with open(newFile, 'rb') as new:
new = new.read()
except FileNotFoundError:
logger.warn('That file does not exist. Improper path?')
else:
logger.debug(new)
self.onionrCore.insertBlock(new, header='bin')
logger.info(self.onionrCore.insertBlock(new, header='bin'))
Onionr()