Skip to content

Commit

Permalink
chore: improve comments on cache and farmer's SUBJECT
Browse files Browse the repository at this point in the history
  • Loading branch information
tediou5 committed Jan 20, 2025
1 parent 942a883 commit 4246b58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion crates/subspace-farmer/src/cluster/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const MIN_CACHE_IDENTIFICATION_INTERVAL: Duration = Duration::from_secs(1);
pub struct ClusterCacheDetailsRequest;

impl GenericStreamRequest for ClusterCacheDetailsRequest {
/// `*` here stands for cache group
/// `*` here stands for cache ID
const SUBJECT: &'static str = "subspace.cache.*.details";
type Response = ClusterPieceCacheDetails;
}
Expand Down Expand Up @@ -67,6 +67,7 @@ struct ClusterCacheWritePieceRequest {
}

impl GenericRequest for ClusterCacheWritePieceRequest {
/// `*` here stands for cache ID
const SUBJECT: &'static str = "subspace.cache.*.write-piece";
type Response = Result<(), String>;
}
Expand All @@ -78,6 +79,7 @@ struct ClusterCacheReadPieceIndexRequest {
}

impl GenericRequest for ClusterCacheReadPieceIndexRequest {
/// `*` here stands for cache ID
const SUBJECT: &'static str = "subspace.cache.*.read-piece-index";
type Response = Result<Option<PieceIndex>, String>;
}
Expand All @@ -89,6 +91,7 @@ pub(super) struct ClusterCacheReadPieceRequest {
}

impl GenericRequest for ClusterCacheReadPieceRequest {
/// `*` here stands for cache ID
const SUBJECT: &'static str = "subspace.cache.*.read-piece";
type Response = Result<Option<(PieceIndex, Piece)>, String>;
}
Expand All @@ -100,6 +103,7 @@ pub(super) struct ClusterCacheReadPiecesRequest {
}

impl GenericStreamRequest for ClusterCacheReadPiecesRequest {
/// `*` here stands for cache ID
const SUBJECT: &'static str = "subspace.cache.*.read-pieces";
type Response = Result<(PieceCacheOffset, Option<(PieceIndex, Piece)>), String>;
}
Expand All @@ -109,6 +113,7 @@ impl GenericStreamRequest for ClusterCacheReadPiecesRequest {
struct ClusterCacheContentsRequest;

impl GenericStreamRequest for ClusterCacheContentsRequest {
/// `*` here stands for cache ID
const SUBJECT: &'static str = "subspace.cache.*.contents";
type Response = Result<(PieceCacheOffset, Option<PieceIndex>), String>;
}
Expand Down
11 changes: 9 additions & 2 deletions crates/subspace-farmer/src/cluster/farmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ const MIN_FARMER_IDENTIFICATION_INTERVAL: Duration = Duration::from_secs(1);

type Handler<A> = Bag<HandlerFn<A>, A>;

/// Broadcast with farmer id for identification
/// Broadcast with cluster farmer id for identification
#[derive(Debug, Clone, Encode, Decode)]
pub struct ClusterFarmerIdentifyBroadcast {
/// Farmer ID
/// Cluster farmer ID
pub farmer_id: FarmerId,
/// Farmer fingerprint changes when something about internal farm changes (like allocated space)
pub fingerprint: Blake3Hash,
}

impl GenericBroadcast for ClusterFarmerIdentifyBroadcast {
/// `*` here stands for cluster farmer ID
const SUBJECT: &'static str = "subspace.farmer.*.farmer-identify";
}

Expand All @@ -58,6 +59,7 @@ impl GenericBroadcast for ClusterFarmerIdentifyBroadcast {
pub struct ClusterFarmerFarmDetailsRequest;

impl GenericStreamRequest for ClusterFarmerFarmDetailsRequest {
/// `*` here stands for cluster farmer ID
const SUBJECT: &'static str = "subspace.farmer.*.farm.details";
type Response = ClusterFarmerFarmDetails;
}
Expand Down Expand Up @@ -85,6 +87,7 @@ struct ClusterFarmerSectorUpdateBroadcast {
}

impl GenericBroadcast for ClusterFarmerSectorUpdateBroadcast {
/// `*` here stands for single farm ID
const SUBJECT: &'static str = "subspace.farmer.*.sector-update";
}

Expand All @@ -98,6 +101,7 @@ struct ClusterFarmerFarmingNotificationBroadcast {
}

impl GenericBroadcast for ClusterFarmerFarmingNotificationBroadcast {
/// `*` here stands for single farm ID
const SUBJECT: &'static str = "subspace.farmer.*.farming-notification";
}

Expand All @@ -111,6 +115,7 @@ struct ClusterFarmerSolutionBroadcast {
}

impl GenericBroadcast for ClusterFarmerSolutionBroadcast {
/// `*` here stands for single farm ID
const SUBJECT: &'static str = "subspace.farmer.*.solution-response";
}

Expand All @@ -122,6 +127,7 @@ struct ClusterFarmerReadPieceRequest {
}

impl GenericRequest for ClusterFarmerReadPieceRequest {
/// `*` here stands for single farm ID
const SUBJECT: &'static str = "subspace.farmer.*.farm.read-piece";
type Response = Result<Option<Piece>, String>;
}
Expand All @@ -131,6 +137,7 @@ impl GenericRequest for ClusterFarmerReadPieceRequest {
struct ClusterFarmerPlottedSectorsRequest;

impl GenericStreamRequest for ClusterFarmerPlottedSectorsRequest {
/// `*` here stands for single farm ID
const SUBJECT: &'static str = "subspace.farmer.*.farm.plotted-sectors";
type Response = Result<PlottedSector, String>;
}
Expand Down

0 comments on commit 4246b58

Please sign in to comment.