From c39a6f3b79604f88d54fc6efbd6345eb810ac9e6 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Fri, 20 Sep 2024 06:33:18 +0300 Subject: [PATCH] Fix sector plotting getting stuck --- .../src/single_disk_farm/plotting.rs | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/crates/subspace-farmer/src/single_disk_farm/plotting.rs b/crates/subspace-farmer/src/single_disk_farm/plotting.rs index 1e0f7d4615..bf779789f3 100644 --- a/crates/subspace-farmer/src/single_disk_farm/plotting.rs +++ b/crates/subspace-farmer/src/single_disk_farm/plotting.rs @@ -176,8 +176,6 @@ where process_plotting_result( maybe_sector_plotting_result?, &mut metadata_header, - sectors_metadata, - sectors_being_modified, Arc::clone(§or_plotting_options.metadata_file) ).await?; } @@ -188,8 +186,6 @@ where process_plotting_result( maybe_sector_plotting_result?, &mut metadata_header, - sectors_metadata, - sectors_being_modified, Arc::clone(§or_plotting_options.metadata_file) ).await?; } @@ -202,31 +198,15 @@ where async fn process_plotting_result( sector_plotting_result: SectorPlottingResult, metadata_header: &mut PlotMetadataHeader, - sectors_metadata: &AsyncRwLock>, - sectors_being_modified: &AsyncRwLock>, #[cfg(not(windows))] metadata_file: Arc, #[cfg(windows)] metadata_file: Arc, ) -> Result<(), PlottingError> { let SectorPlottingResult { sector_index, - sector_metadata, replotting, last_queued, } = sector_plotting_result; - { - let mut sectors_metadata = sectors_metadata.write().await; - // If exists then we're replotting, otherwise we create sector for the first time - if let Some(existing_sector_metadata) = sectors_metadata.get_mut(sector_index as usize) { - *existing_sector_metadata = sector_metadata; - } else { - sectors_metadata.push(sector_metadata); - } - } - - // Inform others that this sector is no longer being modified - sectors_being_modified.write().await.remove(§or_index); - if sector_index + 1 > metadata_header.plotted_sector_count { metadata_header.plotted_sector_count = sector_index + 1; @@ -270,7 +250,6 @@ enum PlotSingleSectorResult { struct SectorPlottingResult { sector_index: SectorIndex, - sector_metadata: SectorMetadataChecksummed, replotting: bool, last_queued: bool, } @@ -486,9 +465,22 @@ where .sector_update .call_simple(&(sector_index, sector_state)); + { + let mut sectors_metadata = sectors_metadata.write().await; + // If exists then we're replotting, otherwise we create sector for the first time + if let Some(existing_sector_metadata) = sectors_metadata.get_mut(sector_index as usize) + { + *existing_sector_metadata = sector_metadata; + } else { + sectors_metadata.push(sector_metadata); + } + } + + // Inform others that this sector is no longer being modified + sectors_being_modified.write().await.remove(§or_index); + Ok(SectorPlottingResult { sector_index, - sector_metadata, replotting, last_queued, })