diff --git a/crates/subspace-farmer/src/piece_cache.rs b/crates/subspace-farmer/src/piece_cache.rs index 7248deb3d6..db0463f7c4 100644 --- a/crates/subspace-farmer/src/piece_cache.rs +++ b/crates/subspace-farmer/src/piece_cache.rs @@ -6,6 +6,7 @@ use parking_lot::RwLock; use rayon::prelude::*; use std::collections::HashMap; use std::mem; +use std::num::NonZeroU16; use std::sync::Arc; use subspace_core_primitives::{Piece, PieceIndex, SegmentIndex}; use subspace_farmer_components::plotting::{PieceGetter, PieceGetterRetryPolicy}; @@ -20,6 +21,8 @@ const WORKER_CHANNEL_CAPACITY: usize = 100; /// Make caches available as they are building without waiting for the initialization to finish, /// this number defines an interval in pieces after which cache is updated const INTERMEDIATE_CACHE_UPDATE_INTERVAL: usize = 100; +/// Get piece retry attempts number. +const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed"); #[derive(Debug, Clone)] struct DiskPieceCacheState { @@ -255,7 +258,10 @@ where // TODO: Can probably do concurrency here for (index, piece_index) in piece_indices_to_store.into_values().enumerate() { let result = piece_getter - .get_piece(piece_index, PieceGetterRetryPolicy::Limited(1)) + .get_piece( + piece_index, + PieceGetterRetryPolicy::Limited(PIECE_GETTER_RETRY_NUMBER.get()), + ) .await; let piece = match result { @@ -432,7 +438,10 @@ where trace!(%piece_index, "Piece needs to be cached #1"); let result = piece_getter - .get_piece(piece_index, PieceGetterRetryPolicy::Limited(1)) + .get_piece( + piece_index, + PieceGetterRetryPolicy::Limited(PIECE_GETTER_RETRY_NUMBER.get()), + ) .await; let piece = match result { diff --git a/crates/subspace-farmer/src/single_disk_farm/plotting.rs b/crates/subspace-farmer/src/single_disk_farm/plotting.rs index a60488bd23..4971f6115d 100644 --- a/crates/subspace-farmer/src/single_disk_farm/plotting.rs +++ b/crates/subspace-farmer/src/single_disk_farm/plotting.rs @@ -33,10 +33,10 @@ use thiserror::Error; use tracing::{debug, info, trace, warn}; const FARMER_APP_INFO_RETRY_INTERVAL: Duration = Duration::from_millis(500); -/// Get piece retry attempts number. -const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed"); /// Size of the cache of archived segments for the purposes of faster sector expiration checks. const ARCHIVED_SEGMENTS_CACHE_SIZE: NonZeroUsize = NonZeroUsize::new(1000).expect("Not zero; qed"); +/// Get piece retry attempts number. +const PIECE_GETTER_RETRY_NUMBER: NonZeroU16 = NonZeroU16::new(3).expect("Not zero; qed"); /// Errors that happen during plotting #[derive(Debug, Error)]