Skip to main content

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 ZerostateProof {
56    #[tl(id = "blockchain.zerostateProof.found")]
57    Found { proof: Bytes },
58    #[tl(id = "blockchain.zerostateProof.notFound")]
59    NotFound,
60}
61
62#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
63#[tl(boxed, scheme = "proto.tl")]
64pub enum PersistentStateInfo {
65    #[tl(id = "blockchain.persistentStateInfo.found")]
66    Found {
67        size: NonZeroU64,
68        chunk_size: NonZeroU32,
69    },
70    #[tl(id = "blockchain.persistentStateInfo.notFound")]
71    NotFound,
72}
73
74#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
75#[tl(boxed, scheme = "proto.tl")]
76pub enum ArchiveInfo {
77    #[tl(id = "blockchain.archiveInfo.found", size_hint = 20)]
78    Found {
79        id: u64,
80        size: NonZeroU64,
81        chunk_size: NonZeroU32,
82    },
83    #[tl(id = "blockchain.archiveInfo.tooNew")]
84    TooNew,
85    #[tl(id = "blockchain.archiveInfo.notFound")]
86    NotFound,
87}
88
89#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
90#[tl(boxed, id = "blockchain.broadcast.message", scheme = "proto.tl")]
91pub struct MessageBroadcastRef<'tl> {
92    pub data: &'tl [u8],
93}
94
95#[derive(Debug, Clone, PartialEq, Eq, TlRead, TlWrite)]
96#[tl(boxed, id = "blockchain.blockData", scheme = "proto.tl")]
97pub struct BlockData<T = Bytes> {
98    pub data: T,
99    pub size: NonZeroU32,
100    pub chunk_size: NonZeroU32,
101}
102
103/// Blockchain RPC models.
104pub mod rpc {
105    use super::*;
106
107    #[derive(Debug, Clone, TlRead, TlWrite)]
108    #[tl(boxed, id = "blockchain.getNextKeyBlockIds", scheme = "proto.tl")]
109    pub struct GetNextKeyBlockIds {
110        #[tl(with = "tl_block_id")]
111        pub block_id: tycho_types::models::BlockId,
112        pub max_size: u32,
113    }
114
115    #[derive(Debug, Clone, TlRead, TlWrite)]
116    #[tl(boxed, id = "blockchain.getBlockFull", scheme = "proto.tl")]
117    pub struct GetBlockFull {
118        #[tl(with = "tl_block_id")]
119        pub block_id: tycho_types::models::BlockId,
120    }
121
122    #[derive(Debug, Clone, TlRead, TlWrite)]
123    #[tl(boxed, id = "blockchain.getNextBlockFull", scheme = "proto.tl")]
124    pub struct GetNextBlockFull {
125        #[tl(with = "tl_block_id")]
126        pub prev_block_id: tycho_types::models::BlockId,
127    }
128
129    #[derive(Debug, Clone, TlRead, TlWrite)]
130    #[tl(boxed, id = "blockchain.getBlockDataChunk", scheme = "proto.tl")]
131    pub struct GetBlockDataChunk {
132        #[tl(with = "tl_block_id")]
133        pub block_id: tycho_types::models::BlockId,
134        pub offset: u32,
135    }
136
137    #[derive(Debug, Clone, TlRead, TlWrite)]
138    #[tl(boxed, id = "blockchain.getKeyBlockProof", scheme = "proto.tl")]
139    pub struct GetKeyBlockProof {
140        #[tl(with = "tl_block_id")]
141        pub block_id: tycho_types::models::BlockId,
142    }
143
144    #[derive(Debug, Clone, TlRead, TlWrite)]
145    #[tl(boxed, id = "blockchain.getZerostateProof", scheme = "proto.tl")]
146    pub struct GetZerostateProof;
147
148    #[derive(Debug, Clone, TlRead, TlWrite)]
149    #[tl(
150        boxed,
151        id = "blockchain.getArchiveInfo",
152        size_hint = 4,
153        scheme = "proto.tl"
154    )]
155    pub struct GetArchiveInfo {
156        pub mc_seqno: u32,
157    }
158
159    #[derive(Debug, Clone, TlRead, TlWrite)]
160    #[tl(
161        boxed,
162        id = "blockchain.getArchiveChunk",
163        size_hint = 16,
164        scheme = "proto.tl"
165    )]
166    pub struct GetArchiveChunk {
167        pub archive_id: u64,
168        pub offset: u64,
169    }
170
171    #[derive(Debug, Clone, TlRead, TlWrite)]
172    #[tl(
173        boxed,
174        id = "blockchain.getPersistentShardStateInfo",
175        scheme = "proto.tl"
176    )]
177    pub struct GetPersistentShardStateInfo {
178        #[tl(with = "tl_block_id")]
179        pub block_id: tycho_types::models::BlockId,
180    }
181
182    #[derive(Debug, Clone, TlRead, TlWrite)]
183    #[tl(
184        boxed,
185        id = "blockchain.getPersistentShardStateChunk",
186        scheme = "proto.tl"
187    )]
188    pub struct GetPersistentShardStateChunk {
189        #[tl(with = "tl_block_id")]
190        pub block_id: tycho_types::models::BlockId,
191        pub offset: u64,
192    }
193
194    #[derive(Debug, Clone, TlRead, TlWrite)]
195    #[tl(
196        boxed,
197        id = "blockchain.getPersistentQueueStateInfo",
198        scheme = "proto.tl"
199    )]
200    pub struct GetPersistentQueueStateInfo {
201        #[tl(with = "tl_block_id")]
202        pub block_id: tycho_types::models::BlockId,
203    }
204
205    #[derive(Debug, Clone, TlRead, TlWrite)]
206    #[tl(
207        boxed,
208        id = "blockchain.getPersistentQueueStateChunk",
209        scheme = "proto.tl"
210    )]
211    pub struct GetPersistentQueueStateChunk {
212        #[tl(with = "tl_block_id")]
213        pub block_id: tycho_types::models::BlockId,
214        pub offset: u64,
215    }
216}