celestia_client/
blobstream.rs1use std::sync::Arc;
2
3use celestia_rpc::blobstream::BlobstreamClient;
4
5use crate::Result;
6use crate::client::ClientInner;
7use crate::types::MerkleProof;
8use crate::types::hash::Hash;
9
10pub struct BlobstreamApi {
12 inner: Arc<ClientInner>,
13}
14
15impl BlobstreamApi {
16 pub(crate) fn new(inner: Arc<ClientInner>) -> BlobstreamApi {
17 BlobstreamApi { inner }
18 }
19
20 pub async fn get_data_root_tuple_root(&self, start: u64, end: u64) -> Result<Hash> {
25 Ok(self
26 .inner
27 .rpc
28 .blobstream_get_data_root_tuple_root(start, end)
29 .await?)
30 }
31
32 pub async fn get_data_root_tuple_inclusion_proof(
37 &self,
38 height: u64,
39 start: u64,
40 end: u64,
41 ) -> Result<MerkleProof> {
42 Ok(self
43 .inner
44 .rpc
45 .blobstream_get_data_root_tuple_inclusion_proof(height, start, end)
46 .await?)
47 }
48}
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 use crate::test_utils::ensure_serializable_deserializable;
55
56 #[allow(dead_code)]
57 #[allow(unused_variables)]
58 #[allow(unreachable_code)]
59 #[allow(clippy::diverging_sub_expression)]
60 async fn enforce_serde_bounds() {
61 let api = BlobstreamApi::new(unimplemented!());
63
64 ensure_serializable_deserializable(api.get_data_root_tuple_root(0, 0).await.unwrap());
65
66 ensure_serializable_deserializable(
67 api.get_data_root_tuple_inclusion_proof(0, 0, 0)
68 .await
69 .unwrap(),
70 );
71 }
72}