1pub mod caching_proxy_node_client;
12pub mod rpc_node_client;
13
14use ab_core_primitives::pieces::{Piece, PieceIndex};
15use ab_core_primitives::segments::{SegmentIndex, SuperSegmentHeader, SuperSegmentIndex};
16use ab_farmer_rpc_primitives::{
17 BlockSealInfo, BlockSealResponse, FarmerAppInfo, FarmerShardMembershipInfo, SlotInfo,
18 SolutionResponse,
19};
20use async_trait::async_trait;
21use futures::Stream;
22use std::fmt;
23use std::pin::Pin;
24
25#[async_trait]
27pub trait NodeClient: fmt::Debug + Send + Sync + 'static {
28 async fn farmer_app_info(&self) -> anyhow::Result<FarmerAppInfo>;
30
31 async fn subscribe_slot_info(
33 &self,
34 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SlotInfo> + Send + 'static>>>;
35
36 async fn submit_solution_response(
38 &self,
39 solution_response: SolutionResponse,
40 ) -> anyhow::Result<()>;
41
42 async fn subscribe_block_sealing(
44 &self,
45 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = BlockSealInfo> + Send + 'static>>>;
46
47 async fn submit_block_seal(&self, block_seal: BlockSealResponse) -> anyhow::Result<()>;
49
50 async fn subscribe_new_super_segment_headers(
52 &self,
53 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SuperSegmentHeader> + Send + 'static>>>;
54
55 async fn super_segment_headers(
57 &self,
58 super_segment_indices: Vec<SuperSegmentIndex>,
59 ) -> anyhow::Result<Vec<Option<SuperSegmentHeader>>>;
60
61 async fn super_segment_header_for_segment_index(
63 &self,
64 segment_index: SegmentIndex,
65 ) -> anyhow::Result<Option<SuperSegmentHeader>>;
66
67 async fn piece(&self, piece_index: PieceIndex) -> anyhow::Result<Option<Piece>>;
69
70 async fn update_shard_membership_info(
73 &self,
74 info: FarmerShardMembershipInfo,
75 ) -> anyhow::Result<()>;
76}
77
78#[async_trait]
81pub trait NodeClientExt: NodeClient {
82 async fn cached_super_segment_headers(
87 &self,
88 super_segment_indices: Vec<SuperSegmentIndex>,
89 ) -> anyhow::Result<Vec<Option<SuperSegmentHeader>>>;
90
91 async fn last_super_segment_headers(
97 &self,
98 limit: u32,
99 ) -> anyhow::Result<Vec<Option<SuperSegmentHeader>>>;
100}