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

View File

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

View File

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