2024-01-03 10:24:52 +00:00
|
|
|
use crate::types::{FileInfo, Segment, SegmentWithProof, Status};
|
|
|
|
use jsonrpsee::core::RpcResult;
|
|
|
|
use jsonrpsee::proc_macros::rpc;
|
2024-07-11 06:07:46 +00:00
|
|
|
use shared_types::{DataRoot, FlowProof};
|
2024-05-31 05:11:06 +00:00
|
|
|
use storage::config::ShardConfig;
|
2024-01-03 10:24:52 +00:00
|
|
|
|
|
|
|
#[rpc(server, client, namespace = "zgs")]
|
|
|
|
pub trait Rpc {
|
|
|
|
#[method(name = "getStatus")]
|
|
|
|
async fn get_status(&self) -> RpcResult<Status>;
|
|
|
|
|
|
|
|
#[method(name = "uploadSegment")]
|
|
|
|
async fn upload_segment(&self, segment: SegmentWithProof) -> RpcResult<()>;
|
|
|
|
|
2024-02-06 09:51:31 +00:00
|
|
|
#[method(name = "uploadSegments")]
|
|
|
|
async fn upload_segments(&self, segments: Vec<SegmentWithProof>) -> RpcResult<()>;
|
|
|
|
|
2024-01-03 10:24:52 +00:00
|
|
|
#[method(name = "downloadSegment")]
|
|
|
|
async fn download_segment(
|
|
|
|
&self,
|
|
|
|
data_root: DataRoot,
|
|
|
|
start_index: usize,
|
|
|
|
end_index: usize,
|
|
|
|
) -> RpcResult<Option<Segment>>;
|
|
|
|
|
|
|
|
#[method(name = "downloadSegmentWithProof")]
|
|
|
|
async fn download_segment_with_proof(
|
|
|
|
&self,
|
|
|
|
data_root: DataRoot,
|
|
|
|
index: usize,
|
|
|
|
) -> RpcResult<Option<SegmentWithProof>>;
|
|
|
|
|
|
|
|
#[method(name = "getFileInfo")]
|
|
|
|
async fn get_file_info(&self, data_root: DataRoot) -> RpcResult<Option<FileInfo>>;
|
|
|
|
|
|
|
|
#[method(name = "getFileInfoByTxSeq")]
|
|
|
|
async fn get_file_info_by_tx_seq(&self, tx_seq: u64) -> RpcResult<Option<FileInfo>>;
|
2024-05-31 05:11:06 +00:00
|
|
|
|
|
|
|
#[method(name = "getShardConfig")]
|
|
|
|
async fn get_shard_config(&self) -> RpcResult<ShardConfig>;
|
2024-07-11 06:07:46 +00:00
|
|
|
|
|
|
|
#[method(name = "getSectorProof")]
|
|
|
|
async fn get_sector_proof(
|
|
|
|
&self,
|
|
|
|
sector_index: u64,
|
|
|
|
flow_root: Option<DataRoot>,
|
|
|
|
) -> RpcResult<FlowProof>;
|
2024-01-03 10:24:52 +00:00
|
|
|
}
|