mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-13 12:09:25 +03:00
locks on updates to plot_ids (#3036)
This commit is contained in:
parent
ea10fcb0fe
commit
0810f4ab74
@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from dataclasses import dataclass
|
||||
@ -155,6 +156,7 @@ def load_plots(
|
||||
for paths in plot_filenames.values():
|
||||
all_filenames += paths
|
||||
plot_ids: Set[bytes32] = set()
|
||||
plot_ids_lock = threading.Lock()
|
||||
|
||||
if match_str is not None:
|
||||
log.info(f'Only loading plots that contain "{match_str}" in the file or directory name')
|
||||
@ -177,7 +179,8 @@ def load_plots(
|
||||
return 0, new_provers
|
||||
if stat_info.st_mtime == provers[filename].time_modified:
|
||||
new_provers[filename] = provers[filename]
|
||||
plot_ids.add(provers[filename].prover.get_id())
|
||||
with plot_ids_lock:
|
||||
plot_ids.add(provers[filename].prover.get_id())
|
||||
return stat_info.st_size, new_provers
|
||||
try:
|
||||
prover = DiskProver(str(filename))
|
||||
@ -230,11 +233,11 @@ def load_plots(
|
||||
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())
|
||||
with plot_ids_lock:
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user