From 5f3680b240085a8598e81677d9b7754466bb9ed8 Mon Sep 17 00:00:00 2001 From: tediou5 Date: Fri, 17 Jan 2025 11:10:14 +0800 Subject: [PATCH] chore: improve comments on cache and farmer's SUBJECT --- crates/subspace-farmer/src/cluster/cache.rs | 7 ++++++- crates/subspace-farmer/src/cluster/farmer.rs | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/subspace-farmer/src/cluster/cache.rs b/crates/subspace-farmer/src/cluster/cache.rs index 63eb8a4d6e..fc39e45e20 100644 --- a/crates/subspace-farmer/src/cluster/cache.rs +++ b/crates/subspace-farmer/src/cluster/cache.rs @@ -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; } @@ -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>; } @@ -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, String>; } @@ -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, String>; } @@ -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>; } @@ -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), String>; } diff --git a/crates/subspace-farmer/src/cluster/farmer.rs b/crates/subspace-farmer/src/cluster/farmer.rs index 6ea0c505b9..1903f6491c 100644 --- a/crates/subspace-farmer/src/cluster/farmer.rs +++ b/crates/subspace-farmer/src/cluster/farmer.rs @@ -40,16 +40,17 @@ const MIN_FARMER_IDENTIFICATION_INTERVAL: Duration = Duration::from_secs(1); type Handler = Bag, 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"; } @@ -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; } @@ -85,6 +87,7 @@ struct ClusterFarmerSectorUpdateBroadcast { } impl GenericBroadcast for ClusterFarmerSectorUpdateBroadcast { + /// `*` here stands for single farm ID const SUBJECT: &'static str = "subspace.farmer.*.sector-update"; } @@ -98,6 +101,7 @@ struct ClusterFarmerFarmingNotificationBroadcast { } impl GenericBroadcast for ClusterFarmerFarmingNotificationBroadcast { + /// `*` here stands for single farm ID const SUBJECT: &'static str = "subspace.farmer.*.farming-notification"; } @@ -111,6 +115,7 @@ struct ClusterFarmerSolutionBroadcast { } impl GenericBroadcast for ClusterFarmerSolutionBroadcast { + /// `*` here stands for single farm ID const SUBJECT: &'static str = "subspace.farmer.*.solution-response"; } @@ -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, String>; } @@ -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; }