Skip to content
Snippets Groups Projects
Commit 4bc8a211 authored by Moul's avatar Moul
Browse files

[mod] #194: verify blocks/cert: Use f-string

parent cd1203c7
No related branches found
No related tags found
1 merge request!195#194, #376: Use f-string and sys.exit()
...@@ -44,14 +44,12 @@ def verify_blocks_signatures(from_block, to_block): ...@@ -44,14 +44,12 @@ def verify_blocks_signatures(from_block, to_block):
for chunk_from in bar: for chunk_from in bar:
chunk_size = get_chunk_size(from_block, to_block, chunks_from, chunk_from) chunk_size = get_chunk_size(from_block, to_block, chunks_from, chunk_from)
logging.info( logging.info(
"Processing chunk from block {} to {}".format( f"Processing chunk from block {chunk_from} to {chunk_from + chunk_size}"
chunk_from, chunk_from + chunk_size
)
) )
chunk = get_chunk(client, chunk_size, chunk_from) chunk = get_chunk(client, chunk_size, chunk_from)
for block in chunk: for block in chunk:
block = Block.from_signed_raw(block["raw"] + block["signature"] + "\n") block = Block.from_signed_raw(f'{block["raw"]}{block["signature"]}\n')
verify_block_signature(invalid_blocks_signatures, block) verify_block_signature(invalid_blocks_signatures, block)
display_result(from_block, to_block, invalid_blocks_signatures) display_result(from_block, to_block, invalid_blocks_signatures)
...@@ -63,8 +61,7 @@ def check_passed_blocks_range(client, from_block, to_block): ...@@ -63,8 +61,7 @@ def check_passed_blocks_range(client, from_block, to_block):
to_block = head_number to_block = head_number
if to_block > head_number: if to_block > head_number:
message_exit( message_exit(
"Passed TO_BLOCK argument is bigger than the head block: " f"Passed TO_BLOCK argument is bigger than the head block: {str(head_number)}"
+ str(head_number)
) )
if from_block > to_block: if from_block > to_block:
message_exit("TO_BLOCK should be bigger or equal to FROM_BLOCK") message_exit("TO_BLOCK should be bigger or equal to FROM_BLOCK")
......
...@@ -99,7 +99,7 @@ def pre_checks(client, issuer_pubkey, pubkey_to_certify): ...@@ -99,7 +99,7 @@ def pre_checks(client, issuer_pubkey, pubkey_to_certify):
renewable = cert["expiresIn"] - params["sigValidity"] + params["sigReplay"] renewable = cert["expiresIn"] - params["sigValidity"] + params["sigReplay"]
if renewable > 0: if renewable > 0:
renewable_date = now().add(seconds=renewable).format(DATE) renewable_date = now().add(seconds=renewable).format(DATE)
sys.exit("Certification renewable from " + renewable_date) sys.exit(f"Certification renewable from {renewable_date}")
# Check if the certification is already in the pending certifications # Check if the certification is already in the pending certifications
for pending_cert in req["pendingCerts"]: for pending_cert in req["pendingCerts"]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment