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 SegmentIndex, SuperSegmentHeader, SuperSegmentIndex, SuperSegmentRoot,
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_new_super_segment_headers(
54 &self,
55 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SuperSegmentHeader> + 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 super_segment_root_for_segment_index(
65 &self,
66 segment_index: SegmentIndex,
67 ) -> anyhow::Result<Option<SuperSegmentRoot>>;
68
69 async fn piece(&self, piece_index: PieceIndex) -> anyhow::Result<Option<Piece>>;
71
72 async fn update_shard_membership_info(
75 &self,
76 info: FarmerShardMembershipInfo,
77 ) -> anyhow::Result<()>;
78}
79
80#[async_trait]
83pub trait NodeClientExt: NodeClient {
84 async fn cached_super_segment_headers(
89 &self,
90 super_segment_indices: Vec<SuperSegmentIndex>,
91 ) -> anyhow::Result<Vec<Option<SuperSegmentHeader>>>;
92
93 async fn last_super_segment_headers(
99 &self,
100 limit: u32,
101 ) -> anyhow::Result<Vec<Option<SuperSegmentHeader>>>;
102}