0g-storage-node/node/rpc/src/zgs/api.rs

88 lines
2.6 KiB
Rust
Raw Normal View History

2024-01-03 10:24:52 +00:00
use crate::types::{FileInfo, Segment, SegmentWithProof, Status};
use jsonrpsee::core::RpcResult;
use jsonrpsee::proc_macros::rpc;
use shared_types::{DataRoot, FlowProof, TxSeqOrRoot};
2024-10-15 06:24:56 +00:00
use storage::{config::ShardConfig, H256};
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-10-10 06:57:40 +00:00
#[method(name = "uploadSegmentByTxSeq")]
async fn upload_segment_by_tx_seq(
&self,
segment: SegmentWithProof,
tx_seq: u64,
) -> RpcResult<()>;
#[method(name = "uploadSegments")]
async fn upload_segments(&self, segments: Vec<SegmentWithProof>) -> RpcResult<()>;
2024-10-10 06:57:40 +00:00
#[method(name = "uploadSegmentsByTxSeq")]
async fn upload_segments_by_tx_seq(
&self,
segments: Vec<SegmentWithProof>,
tx_seq: u64,
) -> 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>>;
2024-10-10 06:57:40 +00:00
#[method(name = "downloadSegmentByTxSeq")]
async fn download_segment_by_tx_seq(
&self,
tx_seq: u64,
start_index: usize,
end_index: usize,
) -> RpcResult<Option<Segment>>;
2024-01-03 10:24:52 +00:00
#[method(name = "downloadSegmentWithProof")]
async fn download_segment_with_proof(
&self,
data_root: DataRoot,
index: usize,
) -> RpcResult<Option<SegmentWithProof>>;
2024-10-10 06:57:40 +00:00
#[method(name = "downloadSegmentWithProofByTxSeq")]
async fn download_segment_with_proof_by_tx_seq(
&self,
tx_seq: u64,
index: usize,
) -> RpcResult<Option<SegmentWithProof>>;
#[method(name = "checkFileFinalized")]
async fn check_file_finalized(&self, tx_seq_or_root: TxSeqOrRoot) -> RpcResult<Option<bool>>;
2024-01-03 10:24:52 +00:00
#[method(name = "getFileInfo")]
async fn get_file_info(
&self,
data_root: DataRoot,
need_available: bool,
) -> RpcResult<Option<FileInfo>>;
2024-01-03 10:24:52 +00:00
#[method(name = "getFileInfoByTxSeq")]
async fn get_file_info_by_tx_seq(&self, tx_seq: u64) -> RpcResult<Option<FileInfo>>;
#[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-10-15 06:24:56 +00:00
#[method(name = "getFlowContext")]
async fn get_flow_context(&self) -> RpcResult<(H256, u64)>;
2024-01-03 10:24:52 +00:00
}