fix some bytes for uploading

master
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:
pass
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
metadata = metas[0]
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
invalid.append(x)
for x in invalid:
newPeers.remove(x)
try:
newPeers.remove(x)
except ValueError:
pass
comm_inst.newPeers.extend(newPeers)
comm_inst.decrementThreadCount('lookup_new_peer_transports_with_communicator')

View File

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

View File

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