bug fixes

This commit is contained in:
Kevin Froman 2018-10-02 11:45:56 -05:00
parent 0b9bb42927
commit 15877449f8
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 11 additions and 5 deletions

View File

@ -220,7 +220,7 @@ class OnionrCommunicatorDaemon:
logger.info("Attempting to download %s..." % blockHash) logger.info("Attempting to download %s..." % blockHash)
peerUsed = self.pickOnlinePeer() peerUsed = self.pickOnlinePeer()
content = self.peerAction(peerUsed, 'getData', data=blockHash) # block content from random peer (includes metadata) content = self.peerAction(peerUsed, 'getData', data=blockHash) # block content from random peer (includes metadata)
if content != False: if content != False and len(content) > 0:
try: try:
content = content.encode() content = content.encode()
except AttributeError: except AttributeError:
@ -266,7 +266,10 @@ class OnionrCommunicatorDaemon:
onionrpeers.PeerProfiles(peerUsed, self._core).addScore(-50) onionrpeers.PeerProfiles(peerUsed, self._core).addScore(-50)
logger.warn('Block hash validation failed for ' + blockHash + ' got ' + tempHash) logger.warn('Block hash validation failed for ' + blockHash + ' got ' + tempHash)
if removeFromQueue: if removeFromQueue:
self.blockQueue.remove(blockHash) # remove from block queue both if success or false try:
self.blockQueue.remove(blockHash) # remove from block queue both if success or false
except ValueError:
pass
self.currentDownloading.remove(blockHash) self.currentDownloading.remove(blockHash)
self.decrementThreadCount('getBlocks') self.decrementThreadCount('getBlocks')
return return

View File

@ -76,7 +76,7 @@ class OnionrCrypto:
try: try:
key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder) key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder)
except nacl.exceptions.ValueError: except nacl.exceptions.ValueError:
logger.warn('Signature by unknown key (cannot reverse hash)') #logger.debug('Signature by unknown key (cannot reverse hash)')
return False return False
except binascii.Error: except binascii.Error:
logger.warn('Could not load key for verification, invalid padding') logger.warn('Could not load key for verification, invalid padding')

View File

@ -68,6 +68,7 @@ class OnionrMail:
pmBlocks = {} pmBlocks = {}
logger.info('Decrypting messages...') logger.info('Decrypting messages...')
choice = '' choice = ''
displayList = []
# this could use a lot of memory if someone has recieved a lot of messages # this could use a lot of memory if someone has recieved a lot of messages
for blockHash in self.myCore.getBlocksByType('pm'): for blockHash in self.myCore.getBlocksByType('pm'):
@ -93,8 +94,10 @@ class OnionrMail:
senderDisplay = senderKey senderDisplay = senderKey
blockDate = pmBlocks[blockHash].getDate().strftime("%m/%d %H:%M") blockDate = pmBlocks[blockHash].getDate().strftime("%m/%d %H:%M")
print('%s. %s - %s: %s' % (blockCount, blockDate, senderDisplay[:12], blockHash)) displayList.append('%s. %s - %s: %s' % (blockCount, blockDate, senderDisplay[:12], blockHash))
#displayList.reverse()
for i in displayList:
print(i)
try: try:
choice = logger.readline('Enter a block number, -r to refresh, or -q to stop: ').strip().lower() choice = logger.readline('Enter a block number, -r to refresh, or -q to stop: ').strip().lower()
except (EOFError, KeyboardInterrupt): except (EOFError, KeyboardInterrupt):