From 0d8cfa1cff0c5290d2a7a4d33d1a187353b5b40c Mon Sep 17 00:00:00 2001 From: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Date: Wed, 14 Apr 2021 13:21:14 +0900 Subject: [PATCH] Plot tools fixes (#1848) * Reduce chance of race conditions, and don't throw when we don't have plots * use cleaner initial value --- chia/plotting/plot_tools.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/chia/plotting/plot_tools.py b/chia/plotting/plot_tools.py index 935ae9bb72e6..822ea0e342d8 100644 --- a/chia/plotting/plot_tools.py +++ b/chia/plotting/plot_tools.py @@ -195,10 +195,6 @@ def load_plots( ) return 0, new_provers - if prover.get_id() in plot_ids: - log.warning(f"Have multiple copies of the plot {filename}, not adding it.") - return 0, new_provers - ( pool_public_key_or_puzzle_hash, farmer_public_key, @@ -233,6 +229,13 @@ def load_plots( stat_info = filename.stat() local_sk = master_sk_to_local_sk(local_master_sk) plot_public_key: G1Element = ProofOfSpace.generate_plot_public_key(local_sk.get_g1(), farmer_public_key) + + if prover.get_id() in plot_ids: + log.warning(f"Have multiple copies of the plot {filename}, not adding it.") + return 0, new_provers + + plot_ids.add(prover.get_id()) + new_provers[filename] = PlotInfo( prover, pool_public_key, @@ -241,7 +244,7 @@ def load_plots( stat_info.st_size, stat_info.st_mtime, ) - plot_ids.add(prover.get_id()) + changed = True except Exception as e: tb = traceback.format_exc() @@ -268,7 +271,8 @@ def load_plots( return total_size1 + total_size2, {**new_provers1, **new_provers2} with ThreadPoolExecutor() as executor: - total_size, new_provers = reduce(reduce_function, executor.map(process_file, all_filenames)) + initial_value: Tuple[int, Dict[Path, PlotInfo]] = (0, {}) + total_size, new_provers = reduce(reduce_function, executor.map(process_file, all_filenames), initial_value) log.info( f"Loaded a total of {len(new_provers)} plots of size {total_size / (1024 ** 4)} TiB, in"