Skip to content

Commit d71b5b6

Browse files
committed
Make sure plotting and piece announcement specifically doesn't block farming
1 parent 68159fa commit d71b5b6

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

crates/subspace-farmer/src/single_disk_plot.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use subspace_rpc_primitives::{SlotInfo, SolutionResponse};
4646
use thiserror::Error;
4747
use tokio::runtime::Handle;
4848
use tokio::sync::broadcast;
49-
use tracing::{debug, error, info, info_span, trace, Instrument, Span};
49+
use tracing::{debug, error, info, info_span, trace, warn, Instrument, Span};
5050
use ulid::Ulid;
5151

5252
// Refuse to compile on non-64-bit platforms, offsets may fail on those when converting from u64 to
@@ -715,23 +715,29 @@ impl SingleDiskPlot {
715715
Err(error) => Err(PlottingError::LowLevel(error))?,
716716
};
717717

718-
let mut metadata_header = metadata_header.lock();
719-
metadata_header.sector_count += 1;
720-
metadata_header_mmap
721-
.copy_from_slice(metadata_header.encode().as_slice());
718+
{
719+
let mut metadata_header = metadata_header.lock();
720+
metadata_header.sector_count += 1;
721+
metadata_header_mmap
722+
.copy_from_slice(metadata_header.encode().as_slice());
723+
}
722724

723725
handlers.sector_plotted.call_simple(&plotted_sector);
724726

725727
// TODO: Migrate this over to using `on_sector_plotted` instead
726728
// Publish pieces-by-sector if we use DSN
727-
let publishing_result = handle.block_on(
728-
piece_publisher.publish_pieces(plotted_sector.piece_indexes),
729-
);
730-
731-
// cancelled
732-
if publishing_result.is_err() {
733-
return;
734-
}
729+
tokio::spawn({
730+
let piece_publisher = piece_publisher.clone();
731+
732+
async move {
733+
if let Err(error) = piece_publisher
734+
.publish_pieces(plotted_sector.piece_indexes)
735+
.await
736+
{
737+
warn!(%sector_index, %error, "Failed to publish pieces to DSN");
738+
}
739+
}
740+
});
735741
}
736742
};
737743

crates/subspace-farmer/src/single_disk_plot/piece_publisher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use tracing::{debug, error, trace};
1414
const PUBLISH_PIECE_BY_SECTOR_WAITING_DURATION_IN_SECS: u64 = 1;
1515

1616
// Piece-by-sector DSN publishing helper.
17+
#[derive(Clone)]
1718
pub(crate) struct PieceSectorPublisher {
1819
dsn_node: Node,
1920
cancelled: Arc<AtomicBool>,

0 commit comments

Comments
 (0)