0g-storage-node/node/rpc/src/admin/api.rs
Bo QIU c2b8b1cab3
Rpc enhancements (#15)
* add admin rpc to terminate file or chunks sync

* Disallow to change file sync goal when failed

* split admin rpc into separate endpoints

* Support to launch public and private rpc at one port

* use one rpc port for python test

* fix lint

* restart to sync file or chunks if sync already completed or failed
2024-01-30 16:50:35 +08:00

36 lines
1.1 KiB
Rust

use crate::types::NetworkInfo;
use jsonrpsee::core::RpcResult;
use jsonrpsee::proc_macros::rpc;
use std::collections::HashMap;
use sync::FileSyncInfo;
#[rpc(server, client, namespace = "admin")]
pub trait Rpc {
#[method(name = "shutdown")]
async fn shutdown(&self) -> RpcResult<()>;
#[method(name = "startSyncFile")]
async fn start_sync_file(&self, tx_seq: u64) -> RpcResult<()>;
#[method(name = "startSyncChunks")]
async fn start_sync_chunks(
&self,
tx_seq: u64,
start_index: u64,
end_index: u64, // exclusive
) -> RpcResult<()>;
/// Terminate file or chunks sync for specified tx_seq.
#[method(name = "terminateSync")]
async fn terminate_sync(&self, tx_seq: u64) -> RpcResult<()>;
#[method(name = "getSyncStatus")]
async fn get_sync_status(&self, tx_seq: u64) -> RpcResult<String>;
#[method(name = "getSyncInfo")]
async fn get_sync_info(&self, tx_seq: Option<u64>) -> RpcResult<HashMap<u64, FileSyncInfo>>;
#[method(name = "getNetworkInfo")]
async fn get_network_info(&self) -> RpcResult<NetworkInfo>;
}