fix some bytes for uploading

This commit is contained in:
Kevin Froman 2019-09-12 01:28:20 -05:00
parent 2ba42ba145
commit 742ef564e1
4 changed files with 9 additions and 4 deletions

View File

@ -77,7 +77,7 @@ def download_blocks_from_communicator(comm_inst):
except AttributeError: except AttributeError:
pass pass
if realHash == blockHash: if realHash == blockHash:
content = content.decode() # decode here because sha3Hash needs bytes above #content = content.decode() # decode here because sha3Hash needs bytes above
metas = blockmetadata.get_block_metadata_from_data(content) # returns tuple(metadata, meta), meta is also in metadata metas = blockmetadata.get_block_metadata_from_data(content) # returns tuple(metadata, meta), meta is also in metadata
metadata = metas[0] metadata = metas[0]
if validatemetadata.validate_metadata(metadata, metas[2]): # check if metadata is valid, and verify nonce if validatemetadata.validate_metadata(metadata, metas[2]): # check if metadata is valid, and verify nonce

View File

@ -47,6 +47,9 @@ def lookup_new_peer_transports_with_communicator(comm_inst):
# avoid adding if its our address # avoid adding if its our address
invalid.append(x) invalid.append(x)
for x in invalid: for x in invalid:
try:
newPeers.remove(x) newPeers.remove(x)
except ValueError:
pass
comm_inst.newPeers.extend(newPeers) comm_inst.newPeers.extend(newPeers)
comm_inst.decrementThreadCount('lookup_new_peer_transports_with_communicator') comm_inst.decrementThreadCount('lookup_new_peer_transports_with_communicator')

View File

@ -72,8 +72,8 @@ class Block:
try: try:
try: try:
self.bcontent = encryption.pub_key_decrypt(self.bcontent, encodedData=encodedData) self.bcontent = encryption.pub_key_decrypt(self.bcontent, encodedData=encodedData)
except binascii.Error: except (binascii.Error, ValueError) as e:
self.bcontent = encryption.pub_key_decrypt(self.bcontent, encodedData=not encodedData) self.bcontent = encryption.pub_key_decrypt(self.bcontent, encodedData=False)
bmeta = encryption.pub_key_decrypt(self.bmetadata, encodedData=encodedData) bmeta = encryption.pub_key_decrypt(self.bmetadata, encodedData=encodedData)
try: try:
bmeta = bmeta.decode() bmeta = bmeta.decode()

View File

@ -1,5 +1,6 @@
from .. import hashers from .. import hashers
import config, onionrproofs, logger import config, onionrproofs, logger
import onionrexceptions
def verify_POW(blockContent): def verify_POW(blockContent):
''' '''
Verifies the proof of work associated with a block Verifies the proof of work associated with a block
@ -31,6 +32,7 @@ def verify_POW(blockContent):
retData = True retData = True
else: else:
logger.debug("Invalid token, bad proof") logger.debug("Invalid token, bad proof")
raise onionrexceptions.InvalidProof('Proof for %s needs to be %s' % (blockHash, puzzle))
return retData return retData