Skip to main content

celestia_rpc/
das.rs

1//! celestia-node rpc types and methods related to DAS (Data Availability Sampling)
2
3use jsonrpsee::{core::RpcResult, proc_macros::rpc};
4use serde::{Deserialize, Serialize};
5
6/// Represents a worker responsible for DAS (Data Availability Sampling) jobs.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct DasWorker {
9    /// Type of the job the worker is performing.
10    pub job_type: String,
11    /// Current progress of the job.
12    pub current: u64,
13    /// The starting height of the job.
14    pub from: u64,
15    /// The ending height of the job.
16    pub to: u64,
17}
18
19/// Response type for [`DasClient::das_sampling_stats`].
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct SamplingStats {
22    /// The height of the most recently sampled block in the chain.
23    pub head_of_sampled_chain: u64,
24    /// The height up to which catch-up has been completed.
25    pub head_of_catchup: u64,
26    /// The current height of the network's head.
27    pub network_head_height: u64,
28    /// The workers assigned to the DAS process.
29    pub workers: Option<Vec<DasWorker>>,
30    /// The number of concurrent DAS jobs running.
31    pub concurrency: u64,
32    /// Whether the DAS process has completed catching up.
33    pub catch_up_done: bool,
34    /// Whether the DAS process is actively running.
35    pub is_running: bool,
36}
37
38/// The `Das` RPC trait provides methods for interacting with Data Availability Sampling.
39#[rpc(client, server, namespace = "das", namespace_separator = ".")]
40pub trait Das {
41    /// Retrieves the current statistics over the DA sampling process.
42    #[method(name = "SamplingStats")]
43    async fn das_sampling_stats(&self) -> RpcResult<SamplingStats>;
44
45    /// Blocks until DASer finishes catching up to the network head.
46    #[method(name = "WaitCatchUp")]
47    async fn das_wait_catch_up(&self) -> RpcResult<()>;
48}