diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs index 19047ad7fc..a5042b2cf1 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs @@ -4,6 +4,7 @@ use prometheus_client::registry::Registry; use std::collections::HashSet; use std::path::Path; use std::sync::{Arc, Weak}; +use subspace_farmer::node_client::NodeClientExt; use subspace_farmer::piece_cache::PieceCache; use subspace_farmer::utils::readers_and_pieces::ReadersAndPieces; use subspace_farmer::{NodeClient, NodeRpcClient, KNOWN_PEERS_CACHE_SIZE}; diff --git a/crates/subspace-farmer/src/node_client.rs b/crates/subspace-farmer/src/node_client.rs index a9bbcb6592..4559e37765 100644 --- a/crates/subspace-farmer/src/node_client.rs +++ b/crates/subspace-farmer/src/node_client.rs @@ -65,7 +65,11 @@ pub trait NodeClient: Clone + fmt::Debug + Send + Sync + 'static { &self, segment_index: SegmentIndex, ) -> Result<(), Error>; +} +/// Node Client extension methods that are not necessary for farmer as a library, but might be useful for an app +#[async_trait] +pub trait NodeClientExt: NodeClient { /// Get the last segment headers. async fn last_segment_headers(&self, limit: u64) -> Result>, Error>; } diff --git a/crates/subspace-farmer/src/node_client/node_rpc_client.rs b/crates/subspace-farmer/src/node_client/node_rpc_client.rs index 4b7a33ce97..b49853192a 100644 --- a/crates/subspace-farmer/src/node_client/node_rpc_client.rs +++ b/crates/subspace-farmer/src/node_client/node_rpc_client.rs @@ -1,4 +1,4 @@ -use crate::node_client::{Error as RpcError, Error, NodeClient}; +use crate::node_client::{Error as RpcError, Error, NodeClient, NodeClientExt}; use async_trait::async_trait; use futures::{Stream, StreamExt}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; @@ -188,7 +188,10 @@ impl NodeClient for NodeRpcClient { ) .await?) } +} +#[async_trait] +impl NodeClientExt for NodeRpcClient { async fn last_segment_headers( &self, limit: u64,