raise exceptions instead of false return in blockimporter

This commit is contained in:
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,
is_json=True,
postData={'block': b_hash}
).get(timeout=5)
).get(timeout=10)
resp = 'success'
else:
resp = 'failure'

View File

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