diff --git a/crates/subspace-farmer/src/cluster/cache.rs b/crates/subspace-farmer/src/cluster/cache.rs
index fe8f5dc40f..3cda8aa79c 100644
--- a/crates/subspace-farmer/src/cluster/cache.rs
+++ b/crates/subspace-farmer/src/cluster/cache.rs
@@ -11,7 +11,7 @@ use crate::cluster::controller::ClusterControllerCacheIdentifyBroadcast;
use crate::cluster::nats_client::{
GenericBroadcast, GenericRequest, GenericStreamRequest, NatsClient,
};
-use crate::farm::{FarmError, PieceCache, PieceCacheId, PieceCacheOffset};
+use crate::farm::{CacheId, FarmError, PieceCache, PieceCacheId, PieceCacheOffset};
use anyhow::anyhow;
use async_trait::async_trait;
use futures::stream::FuturesUnordered;
@@ -27,18 +27,35 @@ use tracing::{debug, error, info, info_span, trace, warn, Instrument};
const MIN_CACHE_IDENTIFICATION_INTERVAL: Duration = Duration::from_secs(1);
+/// Request cache details from cache
+#[derive(Debug, Clone, Encode, Decode)]
+pub struct ClusterCacheDetailsRequest;
+
+impl GenericStreamRequest for ClusterCacheDetailsRequest {
+ /// `*` here stands for cache ID
+ const SUBJECT: &'static str = "subspace.cache.*.details";
+ type Response = ClusterPieceCacheDetails;
+}
+
+/// Cache details
+#[derive(Debug, Clone, Encode, Decode)]
+pub struct ClusterPieceCacheDetails {
+ /// Piece Cache ID
+ pub piece_cache_id: PieceCacheId,
+ /// Max number of elements in this cache
+ pub max_num_elements: u32,
+}
+
/// Broadcast with identification details by caches
#[derive(Debug, Clone, Encode, Decode)]
pub struct ClusterCacheIdentifyBroadcast {
/// Cache ID
- pub cache_id: PieceCacheId,
- /// Max number of elements in this cache
- pub max_num_elements: u32,
+ pub cache_id: CacheId,
}
impl GenericBroadcast for ClusterCacheIdentifyBroadcast {
/// `*` here stands for cache group
- const SUBJECT: &'static str = "subspace.cache.*.identify";
+ const SUBJECT: &'static str = "subspace.cache.*.cache-identify";
}
/// Write piece into cache
@@ -50,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>;
}
@@ -61,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