Skip to content

Commit

Permalink
Merge pull request #2308 from subspace/node-client-ext
Browse files Browse the repository at this point in the history
Split some methods from `NodeClient` into `NodeClientExt`
  • Loading branch information
nazar-pc authored Dec 11, 2023
2 parents e1537f9 + 3745e09 commit b58a025
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 4 additions & 0 deletions crates/subspace-farmer/src/node_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Option<SegmentHeader>>, Error>;
}
5 changes: 4 additions & 1 deletion crates/subspace-farmer/src/node_client/node_rpc_client.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -188,7 +188,10 @@ impl NodeClient for NodeRpcClient {
)
.await?)
}
}

#[async_trait]
impl NodeClientExt for NodeRpcClient {
async fn last_segment_headers(
&self,
limit: u64,
Expand Down

0 comments on commit b58a025

Please sign in to comment.