pub mod caching_proxy_node_client;
pub mod rpc_node_client;
use async_trait::async_trait;
use futures::Stream;
use std::fmt;
use std::pin::Pin;
use subspace_core_primitives::{Piece, PieceIndex, SegmentHeader, SegmentIndex};
use subspace_rpc_primitives::{
FarmerAppInfo, RewardSignatureResponse, RewardSigningInfo, SlotInfo, SolutionResponse,
};
pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
#[async_trait]
pub trait NodeClient: fmt::Debug + Send + Sync + 'static {
async fn farmer_app_info(&self) -> Result<FarmerAppInfo, Error>;
async fn subscribe_slot_info(
&self,
) -> Result<Pin<Box<dyn Stream<Item = SlotInfo> + Send + 'static>>, Error>;
async fn submit_solution_response(
&self,
solution_response: SolutionResponse,
) -> Result<(), Error>;
async fn subscribe_reward_signing(
&self,
) -> Result<Pin<Box<dyn Stream<Item = RewardSigningInfo> + Send + 'static>>, Error>;
async fn submit_reward_signature(
&self,
reward_signature: RewardSignatureResponse,
) -> Result<(), Error>;
async fn subscribe_archived_segment_headers(
&self,
) -> Result<Pin<Box<dyn Stream<Item = SegmentHeader> + Send + 'static>>, Error>;
async fn segment_headers(
&self,
segment_indices: Vec<SegmentIndex>,
) -> Result<Vec<Option<SegmentHeader>>, Error>;
async fn piece(&self, piece_index: PieceIndex) -> Result<Option<Piece>, Error>;
async fn acknowledge_archived_segment_header(
&self,
segment_index: SegmentIndex,
) -> Result<(), Error>;
}
#[async_trait]
pub trait NodeClientExt: NodeClient {
async fn last_segment_headers(&self, limit: u64) -> Result<Vec<Option<SegmentHeader>>, Error>;
}