subspace_farmer/
node_client.rs1pub mod caching_proxy_node_client;
12pub mod rpc_node_client;
13
14use async_trait::async_trait;
15use futures::Stream;
16use std::fmt;
17use std::pin::Pin;
18use subspace_core_primitives::pieces::{Piece, PieceIndex};
19use subspace_core_primitives::segments::{SegmentHeader, SegmentIndex};
20use subspace_rpc_primitives::{
21 FarmerAppInfo, RewardSignatureResponse, RewardSigningInfo, SlotInfo, SolutionResponse,
22};
23
24#[async_trait]
26pub trait NodeClient: fmt::Debug + Send + Sync + 'static {
27 async fn farmer_app_info(&self) -> anyhow::Result<FarmerAppInfo>;
29
30 async fn subscribe_slot_info(
32 &self,
33 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SlotInfo> + Send + 'static>>>;
34
35 async fn submit_solution_response(
37 &self,
38 solution_response: SolutionResponse,
39 ) -> anyhow::Result<()>;
40
41 async fn subscribe_reward_signing(
43 &self,
44 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = RewardSigningInfo> + Send + 'static>>>;
45
46 async fn submit_reward_signature(
48 &self,
49 reward_signature: RewardSignatureResponse,
50 ) -> anyhow::Result<()>;
51
52 async fn subscribe_archived_segment_headers(
54 &self,
55 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SegmentHeader> + Send + 'static>>>;
56
57 async fn segment_headers(
59 &self,
60 segment_indices: Vec<SegmentIndex>,
61 ) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
62
63 async fn piece(&self, piece_index: PieceIndex) -> anyhow::Result<Option<Piece>>;
65
66 async fn acknowledge_archived_segment_header(
68 &self,
69 segment_index: SegmentIndex,
70 ) -> anyhow::Result<()>;
71}
72
73#[async_trait]
75pub trait NodeClientExt: NodeClient {
76 async fn last_segment_headers(&self, limit: u32) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
78}