1pub mod caching_proxy_node_client;
12pub mod rpc_node_client;
13
14use ab_core_primitives::pieces::{Piece, PieceIndex};
15use ab_core_primitives::segments::{SegmentHeader, SegmentIndex};
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_archived_segment_headers(
52 &self,
53 ) -> anyhow::Result<Pin<Box<dyn Stream<Item = SegmentHeader> + Send + 'static>>>;
54
55 async fn segment_headers(
57 &self,
58 segment_indices: Vec<SegmentIndex>,
59 ) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
60
61 async fn piece(&self, piece_index: PieceIndex) -> anyhow::Result<Option<Piece>>;
63
64 async fn acknowledge_archived_segment_header(
66 &self,
67 segment_index: SegmentIndex,
68 ) -> anyhow::Result<()>;
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_segment_headers(
87 &self,
88 segment_indices: Vec<SegmentIndex>,
89 ) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
90
91 async fn last_segment_headers(&self, limit: u32) -> anyhow::Result<Vec<Option<SegmentHeader>>>;
97}