1#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
4pub struct MempoolSubscriptionRequest {
5 #[prost(fixed32, tag = "1")]
9 pub chain_tip: u32,
10}
11#[derive(Clone, PartialEq, ::prost::Message)]
13pub struct MempoolEvent {
14 #[prost(oneof = "mempool_event::Event", tags = "1, 2, 3")]
15 pub event: ::core::option::Option<mempool_event::Event>,
16}
17pub mod mempool_event {
19 #[derive(Clone, PartialEq, ::prost::Message)]
23 pub struct BlockCommitted {
24 #[prost(message, optional, tag = "1")]
25 pub block_header: ::core::option::Option<super::super::blockchain::BlockHeader>,
26 #[prost(message, repeated, tag = "2")]
27 pub transactions: ::prost::alloc::vec::Vec<
28 super::super::transaction::TransactionId,
29 >,
30 }
31 #[derive(Clone, PartialEq, ::prost::Message)]
35 pub struct TransactionAdded {
36 #[prost(message, optional, tag = "1")]
38 pub id: ::core::option::Option<super::super::transaction::TransactionId>,
39 #[prost(message, repeated, tag = "2")]
41 pub nullifiers: ::prost::alloc::vec::Vec<super::super::primitives::Digest>,
42 #[prost(message, repeated, tag = "3")]
44 pub network_notes: ::prost::alloc::vec::Vec<super::super::note::NetworkNote>,
45 #[prost(bytes = "vec", optional, tag = "4")]
50 pub network_account_delta: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
51 }
52 #[derive(Clone, PartialEq, ::prost::Message)]
56 pub struct TransactionsReverted {
57 #[prost(message, repeated, tag = "1")]
58 pub reverted: ::prost::alloc::vec::Vec<super::super::transaction::TransactionId>,
59 }
60 #[derive(Clone, PartialEq, ::prost::Oneof)]
61 pub enum Event {
62 #[prost(message, tag = "1")]
63 TransactionAdded(TransactionAdded),
64 #[prost(message, tag = "2")]
65 BlockCommitted(BlockCommitted),
66 #[prost(message, tag = "3")]
67 TransactionsReverted(TransactionsReverted),
68 }
69}
70pub mod api_client {
72 #![allow(
73 unused_variables,
74 dead_code,
75 missing_docs,
76 clippy::wildcard_imports,
77 clippy::let_unit_value,
78 )]
79 use tonic::codegen::*;
80 use tonic::codegen::http::Uri;
81 #[derive(Debug, Clone)]
82 pub struct ApiClient<T> {
83 inner: tonic::client::Grpc<T>,
84 }
85 impl ApiClient<tonic::transport::Channel> {
86 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
88 where
89 D: TryInto<tonic::transport::Endpoint>,
90 D::Error: Into<StdError>,
91 {
92 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
93 Ok(Self::new(conn))
94 }
95 }
96 impl<T> ApiClient<T>
97 where
98 T: tonic::client::GrpcService<tonic::body::Body>,
99 T::Error: Into<StdError>,
100 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
101 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
102 {
103 pub fn new(inner: T) -> Self {
104 let inner = tonic::client::Grpc::new(inner);
105 Self { inner }
106 }
107 pub fn with_origin(inner: T, origin: Uri) -> Self {
108 let inner = tonic::client::Grpc::with_origin(inner, origin);
109 Self { inner }
110 }
111 pub fn with_interceptor<F>(
112 inner: T,
113 interceptor: F,
114 ) -> ApiClient<InterceptedService<T, F>>
115 where
116 F: tonic::service::Interceptor,
117 T::ResponseBody: Default,
118 T: tonic::codegen::Service<
119 http::Request<tonic::body::Body>,
120 Response = http::Response<
121 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
122 >,
123 >,
124 <T as tonic::codegen::Service<
125 http::Request<tonic::body::Body>,
126 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
127 {
128 ApiClient::new(InterceptedService::new(inner, interceptor))
129 }
130 #[must_use]
135 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
136 self.inner = self.inner.send_compressed(encoding);
137 self
138 }
139 #[must_use]
141 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
142 self.inner = self.inner.accept_compressed(encoding);
143 self
144 }
145 #[must_use]
149 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
150 self.inner = self.inner.max_decoding_message_size(limit);
151 self
152 }
153 #[must_use]
157 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
158 self.inner = self.inner.max_encoding_message_size(limit);
159 self
160 }
161 pub async fn status(
163 &mut self,
164 request: impl tonic::IntoRequest<()>,
165 ) -> std::result::Result<
166 tonic::Response<super::super::rpc::BlockProducerStatus>,
167 tonic::Status,
168 > {
169 self.inner
170 .ready()
171 .await
172 .map_err(|e| {
173 tonic::Status::unknown(
174 format!("Service was not ready: {}", e.into()),
175 )
176 })?;
177 let codec = tonic_prost::ProstCodec::default();
178 let path = http::uri::PathAndQuery::from_static(
179 "/block_producer.Api/Status",
180 );
181 let mut req = request.into_request();
182 req.extensions_mut().insert(GrpcMethod::new("block_producer.Api", "Status"));
183 self.inner.unary(req, path, codec).await
184 }
185 pub async fn submit_proven_transaction(
187 &mut self,
188 request: impl tonic::IntoRequest<
189 super::super::transaction::ProvenTransaction,
190 >,
191 ) -> std::result::Result<
192 tonic::Response<super::super::blockchain::BlockNumber>,
193 tonic::Status,
194 > {
195 self.inner
196 .ready()
197 .await
198 .map_err(|e| {
199 tonic::Status::unknown(
200 format!("Service was not ready: {}", e.into()),
201 )
202 })?;
203 let codec = tonic_prost::ProstCodec::default();
204 let path = http::uri::PathAndQuery::from_static(
205 "/block_producer.Api/SubmitProvenTransaction",
206 );
207 let mut req = request.into_request();
208 req.extensions_mut()
209 .insert(
210 GrpcMethod::new("block_producer.Api", "SubmitProvenTransaction"),
211 );
212 self.inner.unary(req, path, codec).await
213 }
214 pub async fn submit_proven_batch(
227 &mut self,
228 request: impl tonic::IntoRequest<
229 super::super::transaction::ProvenTransactionBatch,
230 >,
231 ) -> std::result::Result<
232 tonic::Response<super::super::blockchain::BlockNumber>,
233 tonic::Status,
234 > {
235 self.inner
236 .ready()
237 .await
238 .map_err(|e| {
239 tonic::Status::unknown(
240 format!("Service was not ready: {}", e.into()),
241 )
242 })?;
243 let codec = tonic_prost::ProstCodec::default();
244 let path = http::uri::PathAndQuery::from_static(
245 "/block_producer.Api/SubmitProvenBatch",
246 );
247 let mut req = request.into_request();
248 req.extensions_mut()
249 .insert(GrpcMethod::new("block_producer.Api", "SubmitProvenBatch"));
250 self.inner.unary(req, path, codec).await
251 }
252 pub async fn mempool_subscription(
263 &mut self,
264 request: impl tonic::IntoRequest<super::MempoolSubscriptionRequest>,
265 ) -> std::result::Result<
266 tonic::Response<tonic::codec::Streaming<super::MempoolEvent>>,
267 tonic::Status,
268 > {
269 self.inner
270 .ready()
271 .await
272 .map_err(|e| {
273 tonic::Status::unknown(
274 format!("Service was not ready: {}", e.into()),
275 )
276 })?;
277 let codec = tonic_prost::ProstCodec::default();
278 let path = http::uri::PathAndQuery::from_static(
279 "/block_producer.Api/MempoolSubscription",
280 );
281 let mut req = request.into_request();
282 req.extensions_mut()
283 .insert(GrpcMethod::new("block_producer.Api", "MempoolSubscription"));
284 self.inner.server_streaming(req, path, codec).await
285 }
286 }
287}
288pub mod api_server {
290 #![allow(
291 unused_variables,
292 dead_code,
293 missing_docs,
294 clippy::wildcard_imports,
295 clippy::let_unit_value,
296 )]
297 use tonic::codegen::*;
298 #[async_trait]
300 pub trait Api: std::marker::Send + std::marker::Sync + 'static {
301 async fn status(
303 &self,
304 request: tonic::Request<()>,
305 ) -> std::result::Result<
306 tonic::Response<super::super::rpc::BlockProducerStatus>,
307 tonic::Status,
308 >;
309 async fn submit_proven_transaction(
311 &self,
312 request: tonic::Request<super::super::transaction::ProvenTransaction>,
313 ) -> std::result::Result<
314 tonic::Response<super::super::blockchain::BlockNumber>,
315 tonic::Status,
316 >;
317 async fn submit_proven_batch(
330 &self,
331 request: tonic::Request<super::super::transaction::ProvenTransactionBatch>,
332 ) -> std::result::Result<
333 tonic::Response<super::super::blockchain::BlockNumber>,
334 tonic::Status,
335 >;
336 type MempoolSubscriptionStream: tonic::codegen::tokio_stream::Stream<
338 Item = std::result::Result<super::MempoolEvent, tonic::Status>,
339 >
340 + std::marker::Send
341 + 'static;
342 async fn mempool_subscription(
353 &self,
354 request: tonic::Request<super::MempoolSubscriptionRequest>,
355 ) -> std::result::Result<
356 tonic::Response<Self::MempoolSubscriptionStream>,
357 tonic::Status,
358 >;
359 }
360 #[derive(Debug)]
361 pub struct ApiServer<T> {
362 inner: Arc<T>,
363 accept_compression_encodings: EnabledCompressionEncodings,
364 send_compression_encodings: EnabledCompressionEncodings,
365 max_decoding_message_size: Option<usize>,
366 max_encoding_message_size: Option<usize>,
367 }
368 impl<T> ApiServer<T> {
369 pub fn new(inner: T) -> Self {
370 Self::from_arc(Arc::new(inner))
371 }
372 pub fn from_arc(inner: Arc<T>) -> Self {
373 Self {
374 inner,
375 accept_compression_encodings: Default::default(),
376 send_compression_encodings: Default::default(),
377 max_decoding_message_size: None,
378 max_encoding_message_size: None,
379 }
380 }
381 pub fn with_interceptor<F>(
382 inner: T,
383 interceptor: F,
384 ) -> InterceptedService<Self, F>
385 where
386 F: tonic::service::Interceptor,
387 {
388 InterceptedService::new(Self::new(inner), interceptor)
389 }
390 #[must_use]
392 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
393 self.accept_compression_encodings.enable(encoding);
394 self
395 }
396 #[must_use]
398 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
399 self.send_compression_encodings.enable(encoding);
400 self
401 }
402 #[must_use]
406 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
407 self.max_decoding_message_size = Some(limit);
408 self
409 }
410 #[must_use]
414 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
415 self.max_encoding_message_size = Some(limit);
416 self
417 }
418 }
419 impl<T, B> tonic::codegen::Service<http::Request<B>> for ApiServer<T>
420 where
421 T: Api,
422 B: Body + std::marker::Send + 'static,
423 B::Error: Into<StdError> + std::marker::Send + 'static,
424 {
425 type Response = http::Response<tonic::body::Body>;
426 type Error = std::convert::Infallible;
427 type Future = BoxFuture<Self::Response, Self::Error>;
428 fn poll_ready(
429 &mut self,
430 _cx: &mut Context<'_>,
431 ) -> Poll<std::result::Result<(), Self::Error>> {
432 Poll::Ready(Ok(()))
433 }
434 fn call(&mut self, req: http::Request<B>) -> Self::Future {
435 match req.uri().path() {
436 "/block_producer.Api/Status" => {
437 #[allow(non_camel_case_types)]
438 struct StatusSvc<T: Api>(pub Arc<T>);
439 impl<T: Api> tonic::server::UnaryService<()> for StatusSvc<T> {
440 type Response = super::super::rpc::BlockProducerStatus;
441 type Future = BoxFuture<
442 tonic::Response<Self::Response>,
443 tonic::Status,
444 >;
445 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
446 let inner = Arc::clone(&self.0);
447 let fut = async move {
448 <T as Api>::status(&inner, request).await
449 };
450 Box::pin(fut)
451 }
452 }
453 let accept_compression_encodings = self.accept_compression_encodings;
454 let send_compression_encodings = self.send_compression_encodings;
455 let max_decoding_message_size = self.max_decoding_message_size;
456 let max_encoding_message_size = self.max_encoding_message_size;
457 let inner = self.inner.clone();
458 let fut = async move {
459 let method = StatusSvc(inner);
460 let codec = tonic_prost::ProstCodec::default();
461 let mut grpc = tonic::server::Grpc::new(codec)
462 .apply_compression_config(
463 accept_compression_encodings,
464 send_compression_encodings,
465 )
466 .apply_max_message_size_config(
467 max_decoding_message_size,
468 max_encoding_message_size,
469 );
470 let res = grpc.unary(method, req).await;
471 Ok(res)
472 };
473 Box::pin(fut)
474 }
475 "/block_producer.Api/SubmitProvenTransaction" => {
476 #[allow(non_camel_case_types)]
477 struct SubmitProvenTransactionSvc<T: Api>(pub Arc<T>);
478 impl<
479 T: Api,
480 > tonic::server::UnaryService<
481 super::super::transaction::ProvenTransaction,
482 > for SubmitProvenTransactionSvc<T> {
483 type Response = super::super::blockchain::BlockNumber;
484 type Future = BoxFuture<
485 tonic::Response<Self::Response>,
486 tonic::Status,
487 >;
488 fn call(
489 &mut self,
490 request: tonic::Request<
491 super::super::transaction::ProvenTransaction,
492 >,
493 ) -> Self::Future {
494 let inner = Arc::clone(&self.0);
495 let fut = async move {
496 <T as Api>::submit_proven_transaction(&inner, request).await
497 };
498 Box::pin(fut)
499 }
500 }
501 let accept_compression_encodings = self.accept_compression_encodings;
502 let send_compression_encodings = self.send_compression_encodings;
503 let max_decoding_message_size = self.max_decoding_message_size;
504 let max_encoding_message_size = self.max_encoding_message_size;
505 let inner = self.inner.clone();
506 let fut = async move {
507 let method = SubmitProvenTransactionSvc(inner);
508 let codec = tonic_prost::ProstCodec::default();
509 let mut grpc = tonic::server::Grpc::new(codec)
510 .apply_compression_config(
511 accept_compression_encodings,
512 send_compression_encodings,
513 )
514 .apply_max_message_size_config(
515 max_decoding_message_size,
516 max_encoding_message_size,
517 );
518 let res = grpc.unary(method, req).await;
519 Ok(res)
520 };
521 Box::pin(fut)
522 }
523 "/block_producer.Api/SubmitProvenBatch" => {
524 #[allow(non_camel_case_types)]
525 struct SubmitProvenBatchSvc<T: Api>(pub Arc<T>);
526 impl<
527 T: Api,
528 > tonic::server::UnaryService<
529 super::super::transaction::ProvenTransactionBatch,
530 > for SubmitProvenBatchSvc<T> {
531 type Response = super::super::blockchain::BlockNumber;
532 type Future = BoxFuture<
533 tonic::Response<Self::Response>,
534 tonic::Status,
535 >;
536 fn call(
537 &mut self,
538 request: tonic::Request<
539 super::super::transaction::ProvenTransactionBatch,
540 >,
541 ) -> Self::Future {
542 let inner = Arc::clone(&self.0);
543 let fut = async move {
544 <T as Api>::submit_proven_batch(&inner, request).await
545 };
546 Box::pin(fut)
547 }
548 }
549 let accept_compression_encodings = self.accept_compression_encodings;
550 let send_compression_encodings = self.send_compression_encodings;
551 let max_decoding_message_size = self.max_decoding_message_size;
552 let max_encoding_message_size = self.max_encoding_message_size;
553 let inner = self.inner.clone();
554 let fut = async move {
555 let method = SubmitProvenBatchSvc(inner);
556 let codec = tonic_prost::ProstCodec::default();
557 let mut grpc = tonic::server::Grpc::new(codec)
558 .apply_compression_config(
559 accept_compression_encodings,
560 send_compression_encodings,
561 )
562 .apply_max_message_size_config(
563 max_decoding_message_size,
564 max_encoding_message_size,
565 );
566 let res = grpc.unary(method, req).await;
567 Ok(res)
568 };
569 Box::pin(fut)
570 }
571 "/block_producer.Api/MempoolSubscription" => {
572 #[allow(non_camel_case_types)]
573 struct MempoolSubscriptionSvc<T: Api>(pub Arc<T>);
574 impl<
575 T: Api,
576 > tonic::server::ServerStreamingService<
577 super::MempoolSubscriptionRequest,
578 > for MempoolSubscriptionSvc<T> {
579 type Response = super::MempoolEvent;
580 type ResponseStream = T::MempoolSubscriptionStream;
581 type Future = BoxFuture<
582 tonic::Response<Self::ResponseStream>,
583 tonic::Status,
584 >;
585 fn call(
586 &mut self,
587 request: tonic::Request<super::MempoolSubscriptionRequest>,
588 ) -> Self::Future {
589 let inner = Arc::clone(&self.0);
590 let fut = async move {
591 <T as Api>::mempool_subscription(&inner, request).await
592 };
593 Box::pin(fut)
594 }
595 }
596 let accept_compression_encodings = self.accept_compression_encodings;
597 let send_compression_encodings = self.send_compression_encodings;
598 let max_decoding_message_size = self.max_decoding_message_size;
599 let max_encoding_message_size = self.max_encoding_message_size;
600 let inner = self.inner.clone();
601 let fut = async move {
602 let method = MempoolSubscriptionSvc(inner);
603 let codec = tonic_prost::ProstCodec::default();
604 let mut grpc = tonic::server::Grpc::new(codec)
605 .apply_compression_config(
606 accept_compression_encodings,
607 send_compression_encodings,
608 )
609 .apply_max_message_size_config(
610 max_decoding_message_size,
611 max_encoding_message_size,
612 );
613 let res = grpc.server_streaming(method, req).await;
614 Ok(res)
615 };
616 Box::pin(fut)
617 }
618 _ => {
619 Box::pin(async move {
620 let mut response = http::Response::new(
621 tonic::body::Body::default(),
622 );
623 let headers = response.headers_mut();
624 headers
625 .insert(
626 tonic::Status::GRPC_STATUS,
627 (tonic::Code::Unimplemented as i32).into(),
628 );
629 headers
630 .insert(
631 http::header::CONTENT_TYPE,
632 tonic::metadata::GRPC_CONTENT_TYPE,
633 );
634 Ok(response)
635 })
636 }
637 }
638 }
639 }
640 impl<T> Clone for ApiServer<T> {
641 fn clone(&self) -> Self {
642 let inner = self.inner.clone();
643 Self {
644 inner,
645 accept_compression_encodings: self.accept_compression_encodings,
646 send_compression_encodings: self.send_compression_encodings,
647 max_decoding_message_size: self.max_decoding_message_size,
648 max_encoding_message_size: self.max_encoding_message_size,
649 }
650 }
651 }
652 pub const SERVICE_NAME: &str = "block_producer.Api";
654 impl<T> tonic::server::NamedService for ApiServer<T> {
655 const NAME: &'static str = SERVICE_NAME;
656 }
657}