Skip to content

Commit e190c1c

Browse files
committed
move exception block up to save a level of indentation
1 parent aeac716 commit e190c1c

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

chia/plotting/check_plots.py

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -173,44 +173,15 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
173173
# Some plot errors cause get_qualities_for_challenge to throw a RuntimeError
174174
try:
175175
quality_start_time = round(monotonic() * 1000)
176-
for index, quality_str in enumerate(pr.get_qualities_for_challenge(challenge)):
177-
quality_spent_time = round(monotonic() * 1000) - quality_start_time
178-
if quality_spent_time > 8000:
179-
log.warning(
180-
f"\tLooking up qualities took: {quality_spent_time} ms. This should be below 8 seconds "
181-
f"to minimize risk of losing rewards. Filepath: {plot_path}"
182-
)
183-
else:
184-
log.info(f"\tLooking up qualities took: {quality_spent_time} ms. Filepath: {plot_path}")
185-
186-
# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
187-
try:
188-
proof_start_time = round(monotonic() * 1000)
189-
# TODO : todo_v2_plots handle v2 plots
190-
proof = pr.get_full_proof(challenge, index, parallel_read)
191-
proof_spent_time = round(monotonic() * 1000) - proof_start_time
192-
if proof_spent_time > 15000:
193-
log.warning(
194-
f"\tFinding proof took: {proof_spent_time} ms. This should be below 15 seconds "
195-
f"to minimize risk of losing rewards. Filepath: {plot_path}"
196-
)
197-
else:
198-
log.info(f"\tFinding proof took: {proof_spent_time} ms. Filepath: {plot_path}")
199-
200-
ver_quality_str = v.validate_proof(pr.get_id(), pr.get_size(), challenge, proof)
201-
if quality_str == ver_quality_str:
202-
total_proofs += 1
203-
else:
204-
log.warning(
205-
f"\tQuality doesn't match with proof. Filepath: {plot_path} "
206-
"This can occasionally happen with a compressed plot."
207-
)
208-
except AssertionError as e:
209-
log.error(
210-
f"{type(e)}: {e} error in proving/verifying for plot {plot_path}. Filepath: {plot_path}"
211-
)
212-
caught_exception = True
213-
quality_start_time = round(monotonic() * 1000)
176+
qualities = pr.get_qualities_for_challenge(challenge)
177+
quality_spent_time = round(monotonic() * 1000) - quality_start_time
178+
if quality_spent_time > 8000:
179+
log.warning(
180+
f"\tLooking up qualities took: {quality_spent_time} ms. This should be below 8 seconds "
181+
f"to minimize risk of losing rewards. Filepath: {plot_path}"
182+
)
183+
else:
184+
log.info(f"\tLooking up qualities took: {quality_spent_time} ms. Filepath: {plot_path}")
214185
except KeyboardInterrupt:
215186
log.warning("Interrupted, closing")
216187
return
@@ -224,9 +195,40 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
224195
else:
225196
log.error(f"{type(e)}: {e} error in getting challenge qualities for plot {plot_path}")
226197
caught_exception = True
198+
continue
227199
except Exception as e:
228200
log.error(f"{type(e)}: {e} error in getting challenge qualities for plot {plot_path}")
229201
caught_exception = True
202+
break
203+
204+
for index, quality_str in enumerate(qualities):
205+
# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
206+
try:
207+
proof_start_time = round(monotonic() * 1000)
208+
# TODO : todo_v2_plots handle v2 plots
209+
proof = pr.get_full_proof(challenge, index, parallel_read)
210+
proof_spent_time = round(monotonic() * 1000) - proof_start_time
211+
if proof_spent_time > 15000:
212+
log.warning(
213+
f"\tFinding proof took: {proof_spent_time} ms. This should be below 15 seconds "
214+
f"to minimize risk of losing rewards. Filepath: {plot_path}"
215+
)
216+
else:
217+
log.info(f"\tFinding proof took: {proof_spent_time} ms. Filepath: {plot_path}")
218+
219+
ver_quality_str = v.validate_proof(pr.get_id(), pr.get_size(), challenge, proof)
220+
if quality_str == ver_quality_str:
221+
total_proofs += 1
222+
else:
223+
log.warning(
224+
f"\tQuality doesn't match with proof. Filepath: {plot_path} "
225+
"This can occasionally happen with a compressed plot."
226+
)
227+
except AssertionError as e:
228+
log.error(
229+
f"{type(e)}: {e} error in proving/verifying for plot {plot_path}. Filepath: {plot_path}"
230+
)
231+
caught_exception = True
230232
if caught_exception is True:
231233
break
232234

0 commit comments

Comments
 (0)