miden_node_proto/generated/
validator.rs1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
4pub struct ValidatorStatus {
5 #[prost(string, tag = "1")]
7 pub version: ::prost::alloc::string::String,
8 #[prost(string, tag = "2")]
10 pub status: ::prost::alloc::string::String,
11}
12pub mod api_client {
14 #![allow(
15 unused_variables,
16 dead_code,
17 missing_docs,
18 clippy::wildcard_imports,
19 clippy::let_unit_value,
20 )]
21 use tonic::codegen::*;
22 use tonic::codegen::http::Uri;
23 #[derive(Debug, Clone)]
25 pub struct ApiClient<T> {
26 inner: tonic::client::Grpc<T>,
27 }
28 impl ApiClient<tonic::transport::Channel> {
29 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
31 where
32 D: TryInto<tonic::transport::Endpoint>,
33 D::Error: Into<StdError>,
34 {
35 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
36 Ok(Self::new(conn))
37 }
38 }
39 impl<T> ApiClient<T>
40 where
41 T: tonic::client::GrpcService<tonic::body::Body>,
42 T::Error: Into<StdError>,
43 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
44 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
45 {
46 pub fn new(inner: T) -> Self {
47 let inner = tonic::client::Grpc::new(inner);
48 Self { inner }
49 }
50 pub fn with_origin(inner: T, origin: Uri) -> Self {
51 let inner = tonic::client::Grpc::with_origin(inner, origin);
52 Self { inner }
53 }
54 pub fn with_interceptor<F>(
55 inner: T,
56 interceptor: F,
57 ) -> ApiClient<InterceptedService<T, F>>
58 where
59 F: tonic::service::Interceptor,
60 T::ResponseBody: Default,
61 T: tonic::codegen::Service<
62 http::Request<tonic::body::Body>,
63 Response = http::Response<
64 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
65 >,
66 >,
67 <T as tonic::codegen::Service<
68 http::Request<tonic::body::Body>,
69 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
70 {
71 ApiClient::new(InterceptedService::new(inner, interceptor))
72 }
73 #[must_use]
78 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
79 self.inner = self.inner.send_compressed(encoding);
80 self
81 }
82 #[must_use]
84 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
85 self.inner = self.inner.accept_compressed(encoding);
86 self
87 }
88 #[must_use]
92 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
93 self.inner = self.inner.max_decoding_message_size(limit);
94 self
95 }
96 #[must_use]
100 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
101 self.inner = self.inner.max_encoding_message_size(limit);
102 self
103 }
104 pub async fn status(
106 &mut self,
107 request: impl tonic::IntoRequest<()>,
108 ) -> std::result::Result<
109 tonic::Response<super::ValidatorStatus>,
110 tonic::Status,
111 > {
112 self.inner
113 .ready()
114 .await
115 .map_err(|e| {
116 tonic::Status::unknown(
117 format!("Service was not ready: {}", e.into()),
118 )
119 })?;
120 let codec = tonic_prost::ProstCodec::default();
121 let path = http::uri::PathAndQuery::from_static("/validator.Api/Status");
122 let mut req = request.into_request();
123 req.extensions_mut().insert(GrpcMethod::new("validator.Api", "Status"));
124 self.inner.unary(req, path, codec).await
125 }
126 pub async fn submit_proven_transaction(
128 &mut self,
129 request: impl tonic::IntoRequest<
130 super::super::transaction::ProvenTransaction,
131 >,
132 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
133 self.inner
134 .ready()
135 .await
136 .map_err(|e| {
137 tonic::Status::unknown(
138 format!("Service was not ready: {}", e.into()),
139 )
140 })?;
141 let codec = tonic_prost::ProstCodec::default();
142 let path = http::uri::PathAndQuery::from_static(
143 "/validator.Api/SubmitProvenTransaction",
144 );
145 let mut req = request.into_request();
146 req.extensions_mut()
147 .insert(GrpcMethod::new("validator.Api", "SubmitProvenTransaction"));
148 self.inner.unary(req, path, codec).await
149 }
150 pub async fn sign_block(
152 &mut self,
153 request: impl tonic::IntoRequest<super::super::blockchain::ProposedBlock>,
154 ) -> std::result::Result<
155 tonic::Response<super::super::blockchain::BlockSignature>,
156 tonic::Status,
157 > {
158 self.inner
159 .ready()
160 .await
161 .map_err(|e| {
162 tonic::Status::unknown(
163 format!("Service was not ready: {}", e.into()),
164 )
165 })?;
166 let codec = tonic_prost::ProstCodec::default();
167 let path = http::uri::PathAndQuery::from_static("/validator.Api/SignBlock");
168 let mut req = request.into_request();
169 req.extensions_mut().insert(GrpcMethod::new("validator.Api", "SignBlock"));
170 self.inner.unary(req, path, codec).await
171 }
172 }
173}
174pub mod api_server {
176 #![allow(
177 unused_variables,
178 dead_code,
179 missing_docs,
180 clippy::wildcard_imports,
181 clippy::let_unit_value,
182 )]
183 use tonic::codegen::*;
184 #[async_trait]
186 pub trait Api: std::marker::Send + std::marker::Sync + 'static {
187 async fn status(
189 &self,
190 request: tonic::Request<()>,
191 ) -> std::result::Result<tonic::Response<super::ValidatorStatus>, tonic::Status>;
192 async fn submit_proven_transaction(
194 &self,
195 request: tonic::Request<super::super::transaction::ProvenTransaction>,
196 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
197 async fn sign_block(
199 &self,
200 request: tonic::Request<super::super::blockchain::ProposedBlock>,
201 ) -> std::result::Result<
202 tonic::Response<super::super::blockchain::BlockSignature>,
203 tonic::Status,
204 >;
205 }
206 #[derive(Debug)]
208 pub struct ApiServer<T> {
209 inner: Arc<T>,
210 accept_compression_encodings: EnabledCompressionEncodings,
211 send_compression_encodings: EnabledCompressionEncodings,
212 max_decoding_message_size: Option<usize>,
213 max_encoding_message_size: Option<usize>,
214 }
215 impl<T> ApiServer<T> {
216 pub fn new(inner: T) -> Self {
217 Self::from_arc(Arc::new(inner))
218 }
219 pub fn from_arc(inner: Arc<T>) -> Self {
220 Self {
221 inner,
222 accept_compression_encodings: Default::default(),
223 send_compression_encodings: Default::default(),
224 max_decoding_message_size: None,
225 max_encoding_message_size: None,
226 }
227 }
228 pub fn with_interceptor<F>(
229 inner: T,
230 interceptor: F,
231 ) -> InterceptedService<Self, F>
232 where
233 F: tonic::service::Interceptor,
234 {
235 InterceptedService::new(Self::new(inner), interceptor)
236 }
237 #[must_use]
239 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
240 self.accept_compression_encodings.enable(encoding);
241 self
242 }
243 #[must_use]
245 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
246 self.send_compression_encodings.enable(encoding);
247 self
248 }
249 #[must_use]
253 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
254 self.max_decoding_message_size = Some(limit);
255 self
256 }
257 #[must_use]
261 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
262 self.max_encoding_message_size = Some(limit);
263 self
264 }
265 }
266 impl<T, B> tonic::codegen::Service<http::Request<B>> for ApiServer<T>
267 where
268 T: Api,
269 B: Body + std::marker::Send + 'static,
270 B::Error: Into<StdError> + std::marker::Send + 'static,
271 {
272 type Response = http::Response<tonic::body::Body>;
273 type Error = std::convert::Infallible;
274 type Future = BoxFuture<Self::Response, Self::Error>;
275 fn poll_ready(
276 &mut self,
277 _cx: &mut Context<'_>,
278 ) -> Poll<std::result::Result<(), Self::Error>> {
279 Poll::Ready(Ok(()))
280 }
281 fn call(&mut self, req: http::Request<B>) -> Self::Future {
282 match req.uri().path() {
283 "/validator.Api/Status" => {
284 #[allow(non_camel_case_types)]
285 struct StatusSvc<T: Api>(pub Arc<T>);
286 impl<T: Api> tonic::server::UnaryService<()> for StatusSvc<T> {
287 type Response = super::ValidatorStatus;
288 type Future = BoxFuture<
289 tonic::Response<Self::Response>,
290 tonic::Status,
291 >;
292 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
293 let inner = Arc::clone(&self.0);
294 let fut = async move {
295 <T as Api>::status(&inner, request).await
296 };
297 Box::pin(fut)
298 }
299 }
300 let accept_compression_encodings = self.accept_compression_encodings;
301 let send_compression_encodings = self.send_compression_encodings;
302 let max_decoding_message_size = self.max_decoding_message_size;
303 let max_encoding_message_size = self.max_encoding_message_size;
304 let inner = self.inner.clone();
305 let fut = async move {
306 let method = StatusSvc(inner);
307 let codec = tonic_prost::ProstCodec::default();
308 let mut grpc = tonic::server::Grpc::new(codec)
309 .apply_compression_config(
310 accept_compression_encodings,
311 send_compression_encodings,
312 )
313 .apply_max_message_size_config(
314 max_decoding_message_size,
315 max_encoding_message_size,
316 );
317 let res = grpc.unary(method, req).await;
318 Ok(res)
319 };
320 Box::pin(fut)
321 }
322 "/validator.Api/SubmitProvenTransaction" => {
323 #[allow(non_camel_case_types)]
324 struct SubmitProvenTransactionSvc<T: Api>(pub Arc<T>);
325 impl<
326 T: Api,
327 > tonic::server::UnaryService<
328 super::super::transaction::ProvenTransaction,
329 > for SubmitProvenTransactionSvc<T> {
330 type Response = ();
331 type Future = BoxFuture<
332 tonic::Response<Self::Response>,
333 tonic::Status,
334 >;
335 fn call(
336 &mut self,
337 request: tonic::Request<
338 super::super::transaction::ProvenTransaction,
339 >,
340 ) -> Self::Future {
341 let inner = Arc::clone(&self.0);
342 let fut = async move {
343 <T as Api>::submit_proven_transaction(&inner, request).await
344 };
345 Box::pin(fut)
346 }
347 }
348 let accept_compression_encodings = self.accept_compression_encodings;
349 let send_compression_encodings = self.send_compression_encodings;
350 let max_decoding_message_size = self.max_decoding_message_size;
351 let max_encoding_message_size = self.max_encoding_message_size;
352 let inner = self.inner.clone();
353 let fut = async move {
354 let method = SubmitProvenTransactionSvc(inner);
355 let codec = tonic_prost::ProstCodec::default();
356 let mut grpc = tonic::server::Grpc::new(codec)
357 .apply_compression_config(
358 accept_compression_encodings,
359 send_compression_encodings,
360 )
361 .apply_max_message_size_config(
362 max_decoding_message_size,
363 max_encoding_message_size,
364 );
365 let res = grpc.unary(method, req).await;
366 Ok(res)
367 };
368 Box::pin(fut)
369 }
370 "/validator.Api/SignBlock" => {
371 #[allow(non_camel_case_types)]
372 struct SignBlockSvc<T: Api>(pub Arc<T>);
373 impl<
374 T: Api,
375 > tonic::server::UnaryService<
376 super::super::blockchain::ProposedBlock,
377 > for SignBlockSvc<T> {
378 type Response = super::super::blockchain::BlockSignature;
379 type Future = BoxFuture<
380 tonic::Response<Self::Response>,
381 tonic::Status,
382 >;
383 fn call(
384 &mut self,
385 request: tonic::Request<
386 super::super::blockchain::ProposedBlock,
387 >,
388 ) -> Self::Future {
389 let inner = Arc::clone(&self.0);
390 let fut = async move {
391 <T as Api>::sign_block(&inner, request).await
392 };
393 Box::pin(fut)
394 }
395 }
396 let accept_compression_encodings = self.accept_compression_encodings;
397 let send_compression_encodings = self.send_compression_encodings;
398 let max_decoding_message_size = self.max_decoding_message_size;
399 let max_encoding_message_size = self.max_encoding_message_size;
400 let inner = self.inner.clone();
401 let fut = async move {
402 let method = SignBlockSvc(inner);
403 let codec = tonic_prost::ProstCodec::default();
404 let mut grpc = tonic::server::Grpc::new(codec)
405 .apply_compression_config(
406 accept_compression_encodings,
407 send_compression_encodings,
408 )
409 .apply_max_message_size_config(
410 max_decoding_message_size,
411 max_encoding_message_size,
412 );
413 let res = grpc.unary(method, req).await;
414 Ok(res)
415 };
416 Box::pin(fut)
417 }
418 _ => {
419 Box::pin(async move {
420 let mut response = http::Response::new(
421 tonic::body::Body::default(),
422 );
423 let headers = response.headers_mut();
424 headers
425 .insert(
426 tonic::Status::GRPC_STATUS,
427 (tonic::Code::Unimplemented as i32).into(),
428 );
429 headers
430 .insert(
431 http::header::CONTENT_TYPE,
432 tonic::metadata::GRPC_CONTENT_TYPE,
433 );
434 Ok(response)
435 })
436 }
437 }
438 }
439 }
440 impl<T> Clone for ApiServer<T> {
441 fn clone(&self) -> Self {
442 let inner = self.inner.clone();
443 Self {
444 inner,
445 accept_compression_encodings: self.accept_compression_encodings,
446 send_compression_encodings: self.send_compression_encodings,
447 max_decoding_message_size: self.max_decoding_message_size,
448 max_encoding_message_size: self.max_encoding_message_size,
449 }
450 }
451 }
452 pub const SERVICE_NAME: &str = "validator.Api";
454 impl<T> tonic::server::NamedService for ApiServer<T> {
455 const NAME: &'static str = SERVICE_NAME;
456 }
457}