raise exceptions instead of false return in blockimporter

master
Kevin Froman 2020-01-19 21:10:51 -06:00
parent 3aeb305994
commit 07ab85698d
2 changed files with 6 additions and 2 deletions

View File

@ -46,7 +46,7 @@ def accept_upload(request):
post=True, post=True,
is_json=True, is_json=True,
postData={'block': b_hash} postData={'block': b_hash}
).get(timeout=5) ).get(timeout=10)
resp = 'success' resp = 'success'
else: else:
resp = 'failure' resp = 'failure'

View File

@ -6,6 +6,7 @@
from onionrexceptions import BlacklistedBlock from onionrexceptions import BlacklistedBlock
from onionrexceptions import DiskAllocationReached from onionrexceptions import DiskAllocationReached
from onionrexceptions import InvalidProof from onionrexceptions import InvalidProof
from onionrexceptions import InvalidMetadata
import logger import logger
from onionrutils import validatemetadata from onionrutils import validatemetadata
from onionrutils import blockmetadata from onionrutils import blockmetadata
@ -58,11 +59,14 @@ def import_block_from_data(content):
blockHash = onionrstorage.set_data(content) blockHash = onionrstorage.set_data(content)
except DiskAllocationReached: except DiskAllocationReached:
logger.warn('Failed to save block due to full disk allocation') logger.warn('Failed to save block due to full disk allocation')
raise
else: else:
blockmetadb.add_to_block_DB(blockHash, dataSaved=True) blockmetadb.add_to_block_DB(blockHash, dataSaved=True)
# caches block metadata values to block database # caches block metadata values to block database
blockmetadata.process_block_metadata(blockHash) blockmetadata.process_block_metadata(blockHash)
ret_data = True ret_data = blockHash
else: else:
raise InvalidProof raise InvalidProof
else:
raise InvalidMetadata
return ret_data return ret_data