1pub mod caching_proxy_node_client;
12pub mod rpc_node_client;
13
14use ab_core_primitives::pieces::{Piece, PieceIndex};
15use ab_core_primitives::segments::{
16 SegmentHeader, SegmentIndex, SuperSegmentHeader, SuperSegmentIndex,
17};
18use ab_farmer_rpc_primitives::{
19 BlockSealInfo, BlockSealResponse, FarmerAppInfo, FarmerShardMembershipInfo, SlotInfo,
20 SolutionResponse,
21};
22use async_trait::async_trait;
23use futures::Stream;
24use std::fmt;
25use std::pin::Pin;
26
27#[async_trait]
29pub trait NodeClient: fmt::Debug + Send + Sync + 'static {
30 async fn farmer_app_info(&self) -> anyhow::Result<FarmerAppInfo>;
32
33 async fn subscribe_slot_info(
35 &self,
36 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SlotInfo> + Send + 'static>>>;
37
38 async fn submit_solution_response(
40 &self,
41 solution_response: SolutionResponse,
42 ) -> anyhow::Result<()>;
43
44 async fn subscribe_block_sealing(
46 &self,
47 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = BlockSealInfo> + Send + 'static>>>;
48
49 async fn submit_block_seal(&self, block_seal: BlockSealResponse) -> 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 super_segment_headers(
59 &self,
60 super_segment_indices: Vec<SuperSegmentIndex>,
61 ) -> anyhow::Result<Vec<Option<SuperSegmentHeader>>>;
62
63 async fn segment_headers(
65 &self,
66 segment_indices: Vec<SegmentIndex>,
67 ) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
68
69 async fn piece(&self, piece_index: PieceIndex) -> anyhow::Result<Option<Piece>>;
71
72 async fn acknowledge_archived_segment_header(
74 &self,
75 segment_index: SegmentIndex,
76 ) -> anyhow::Result<()>;
77
78 async fn update_shard_membership_info(
81 &self,
82 info: FarmerShardMembershipInfo,
83 ) -> anyhow::Result<()>;
84}
85
86#[async_trait]
89pub trait NodeClientExt: NodeClient {
90 async fn cached_segment_headers(
95 &self,
96 segment_indices: Vec<SegmentIndex>,
97 ) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
98
99 async fn last_segment_headers(&self, limit: u32) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
105}