tycho_core/proto/
blockchain.rs

1use std::num::{NonZeroU32, NonZeroU64};
2
3use bytes::Bytes;
4use tl_proto::{TlRead, TlWrite};
5use tycho_block_util::tl::{block_id as tl_block_id, block_id_vec as tl_block_id_vec};
6
7/// Data for computing a public overlay id.
8#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
9#[tl(boxed, id = "blockchain.overlayIdData", scheme = "proto.tl")]
10pub struct OverlayIdData {
11    pub zerostate_root_hash: [u8; 32],
12    pub zerostate_file_hash: [u8; 32],
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
16#[tl(boxed, id = "blockchain.data", scheme = "proto.tl")]
17pub struct Data {
18    pub data: Bytes,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
22#[tl(boxed, id = "blockchain.keyBlockIds", scheme = "proto.tl")]
23pub struct KeyBlockIds {
24    #[tl(with = "tl_block_id_vec")]
25    pub block_ids: Vec<tycho_types::models::BlockId>,
26    pub incomplete: bool,
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
30#[tl(boxed, scheme = "proto.tl")]
31pub enum BlockFull {
32    #[tl(id = "blockchain.blockFull.found")]
33    Found {
34        #[tl(with = "tl_block_id")]
35        block_id: tycho_types::models::BlockId,
36        block: BlockData,
37        proof: Bytes,
38        queue_diff: Bytes,
39    },
40    #[tl(id = "blockchain.blockFull.notFound")]
41    NotFound,
42}
43
44#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
45#[tl(boxed, scheme = "proto.tl")]
46pub enum KeyBlockProof {
47    #[tl(id = "blockchain.keyBlockProof.found")]
48    Found { proof: Bytes },
49    #[tl(id = "blockchain.keyBlockProof.notFound")]
50    NotFound,
51}
52
53#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
54#[tl(boxed, scheme = "proto.tl")]
55pub enum PersistentStateInfo {
56    #[tl(id = "blockchain.persistentStateInfo.found")]
57    Found {
58        size: NonZeroU64,
59        chunk_size: NonZeroU32,
60    },
61    #[tl(id = "blockchain.persistentStateInfo.notFound")]
62    NotFound,
63}
64
65#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
66#[tl(boxed, scheme = "proto.tl")]
67pub enum ArchiveInfo {
68    #[tl(id = "blockchain.archiveInfo.found", size_hint = 20)]
69    Found {
70        id: u64,
71        size: NonZeroU64,
72        chunk_size: NonZeroU32,
73    },
74    #[tl(id = "blockchain.archiveInfo.tooNew")]
75    TooNew,
76    #[tl(id = "blockchain.archiveInfo.notFound")]
77    NotFound,
78}
79
80#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
81#[tl(boxed, id = "blockchain.broadcast.message", scheme = "proto.tl")]
82pub struct MessageBroadcastRef<'tl> {
83    pub data: &'tl [u8],
84}
85
86#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
87#[tl(boxed, id = "blockchain.blockData", scheme = "proto.tl")]
88pub struct BlockData<T = Bytes> {
89    pub data: T,
90    pub size: NonZeroU32,
91    pub chunk_size: NonZeroU32,
92}
93
94/// Blockchain RPC models.
95pub mod rpc {
96    use super::*;
97
98    #[derive(Debug, Clone, TlRead, TlWrite)]
99    #[tl(boxed, id = "blockchain.getNextKeyBlockIds", scheme = "proto.tl")]
100    pub struct GetNextKeyBlockIds {
101        #[tl(with = "tl_block_id")]
102        pub block_id: tycho_types::models::BlockId,
103        pub max_size: u32,
104    }
105
106    #[derive(Debug, Clone, TlRead, TlWrite)]
107    #[tl(boxed, id = "blockchain.getBlockFull", scheme = "proto.tl")]
108    pub struct GetBlockFull {
109        #[tl(with = "tl_block_id")]
110        pub block_id: tycho_types::models::BlockId,
111    }
112
113    #[derive(Debug, Clone, TlRead, TlWrite)]
114    #[tl(boxed, id = "blockchain.getNextBlockFull", scheme = "proto.tl")]
115    pub struct GetNextBlockFull {
116        #[tl(with = "tl_block_id")]
117        pub prev_block_id: tycho_types::models::BlockId,
118    }
119
120    #[derive(Debug, Clone, TlRead, TlWrite)]
121    #[tl(boxed, id = "blockchain.getBlockDataChunk", scheme = "proto.tl")]
122    pub struct GetBlockDataChunk {
123        #[tl(with = "tl_block_id")]
124        pub block_id: tycho_types::models::BlockId,
125        pub offset: u32,
126    }
127
128    #[derive(Debug, Clone, TlRead, TlWrite)]
129    #[tl(boxed, id = "blockchain.getKeyBlockProof", scheme = "proto.tl")]
130    pub struct GetKeyBlockProof {
131        #[tl(with = "tl_block_id")]
132        pub block_id: tycho_types::models::BlockId,
133    }
134
135    #[derive(Debug, Clone, TlRead, TlWrite)]
136    #[tl(
137        boxed,
138        id = "blockchain.getArchiveInfo",
139        size_hint = 4,
140        scheme = "proto.tl"
141    )]
142    pub struct GetArchiveInfo {
143        pub mc_seqno: u32,
144    }
145
146    #[derive(Debug, Clone, TlRead, TlWrite)]
147    #[tl(
148        boxed,
149        id = "blockchain.getArchiveChunk",
150        size_hint = 16,
151        scheme = "proto.tl"
152    )]
153    pub struct GetArchiveChunk {
154        pub archive_id: u64,
155        pub offset: u64,
156    }
157
158    #[derive(Debug, Clone, TlRead, TlWrite)]
159    #[tl(
160        boxed,
161        id = "blockchain.getPersistentShardStateInfo",
162        scheme = "proto.tl"
163    )]
164    pub struct GetPersistentShardStateInfo {
165        #[tl(with = "tl_block_id")]
166        pub block_id: tycho_types::models::BlockId,
167    }
168
169    #[derive(Debug, Clone, TlRead, TlWrite)]
170    #[tl(
171        boxed,
172        id = "blockchain.getPersistentShardStateChunk",
173        scheme = "proto.tl"
174    )]
175    pub struct GetPersistentShardStateChunk {
176        #[tl(with = "tl_block_id")]
177        pub block_id: tycho_types::models::BlockId,
178        pub offset: u64,
179    }
180
181    #[derive(Debug, Clone, TlRead, TlWrite)]
182    #[tl(
183        boxed,
184        id = "blockchain.getPersistentQueueStateInfo",
185        scheme = "proto.tl"
186    )]
187    pub struct GetPersistentQueueStateInfo {
188        #[tl(with = "tl_block_id")]
189        pub block_id: tycho_types::models::BlockId,
190    }
191
192    #[derive(Debug, Clone, TlRead, TlWrite)]
193    #[tl(
194        boxed,
195        id = "blockchain.getPersistentQueueStateChunk",
196        scheme = "proto.tl"
197    )]
198    pub struct GetPersistentQueueStateChunk {
199        #[tl(with = "tl_block_id")]
200        pub block_id: tycho_types::models::BlockId,
201        pub offset: u64,
202    }
203}