tendermint_proto/prost/v0_38/
tendermint.rpc.grpc.rs1#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, Copy, PartialEq, ::prost::Message)]
4pub struct RequestPing {}
5#[allow(clippy::derive_partial_eq_without_eq)]
6#[derive(Clone, PartialEq, ::prost::Message)]
7pub struct RequestBroadcastTx {
8 #[prost(bytes = "vec", tag = "1")]
9 pub tx: ::prost::alloc::vec::Vec<u8>,
10}
11#[allow(clippy::derive_partial_eq_without_eq)]
12#[derive(Clone, Copy, PartialEq, ::prost::Message)]
13pub struct ResponsePing {}
14#[allow(clippy::derive_partial_eq_without_eq)]
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct ResponseBroadcastTx {
17 #[prost(message, optional, tag = "1")]
18 pub check_tx: ::core::option::Option<super::super::abci::ResponseCheckTx>,
19 #[prost(message, optional, tag = "2")]
20 pub tx_result: ::core::option::Option<super::super::abci::ExecTxResult>,
21}
22#[cfg(feature = "grpc-server")]
24pub mod broadcast_api_server {
25 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
26 use tonic::codegen::*;
27 #[async_trait]
29 pub trait BroadcastApi: Send + Sync + 'static {
30 async fn ping(
31 &self,
32 request: tonic::Request<super::RequestPing>,
33 ) -> std::result::Result<tonic::Response<super::ResponsePing>, tonic::Status>;
34 async fn broadcast_tx(
35 &self,
36 request: tonic::Request<super::RequestBroadcastTx>,
37 ) -> std::result::Result<
38 tonic::Response<super::ResponseBroadcastTx>,
39 tonic::Status,
40 >;
41 }
42 #[derive(Debug)]
47 pub struct BroadcastApiServer<T: BroadcastApi> {
48 inner: Arc<T>,
49 accept_compression_encodings: EnabledCompressionEncodings,
50 send_compression_encodings: EnabledCompressionEncodings,
51 max_decoding_message_size: Option<usize>,
52 max_encoding_message_size: Option<usize>,
53 }
54 impl<T: BroadcastApi> BroadcastApiServer<T> {
55 pub fn new(inner: T) -> Self {
56 Self::from_arc(Arc::new(inner))
57 }
58 pub fn from_arc(inner: Arc<T>) -> Self {
59 Self {
60 inner,
61 accept_compression_encodings: Default::default(),
62 send_compression_encodings: Default::default(),
63 max_decoding_message_size: None,
64 max_encoding_message_size: None,
65 }
66 }
67 pub fn with_interceptor<F>(
68 inner: T,
69 interceptor: F,
70 ) -> InterceptedService<Self, F>
71 where
72 F: tonic::service::Interceptor,
73 {
74 InterceptedService::new(Self::new(inner), interceptor)
75 }
76 #[must_use]
78 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
79 self.accept_compression_encodings.enable(encoding);
80 self
81 }
82 #[must_use]
84 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
85 self.send_compression_encodings.enable(encoding);
86 self
87 }
88 #[must_use]
92 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
93 self.max_decoding_message_size = Some(limit);
94 self
95 }
96 #[must_use]
100 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
101 self.max_encoding_message_size = Some(limit);
102 self
103 }
104 }
105 impl<T, B> tonic::codegen::Service<http::Request<B>> for BroadcastApiServer<T>
106 where
107 T: BroadcastApi,
108 B: Body + Send + 'static,
109 B::Error: Into<StdError> + Send + 'static,
110 {
111 type Response = http::Response<tonic::body::BoxBody>;
112 type Error = std::convert::Infallible;
113 type Future = BoxFuture<Self::Response, Self::Error>;
114 fn poll_ready(
115 &mut self,
116 _cx: &mut Context<'_>,
117 ) -> Poll<std::result::Result<(), Self::Error>> {
118 Poll::Ready(Ok(()))
119 }
120 fn call(&mut self, req: http::Request<B>) -> Self::Future {
121 match req.uri().path() {
122 "/tendermint.rpc.grpc.BroadcastAPI/Ping" => {
123 #[allow(non_camel_case_types)]
124 struct PingSvc<T: BroadcastApi>(pub Arc<T>);
125 impl<T: BroadcastApi> tonic::server::UnaryService<super::RequestPing>
126 for PingSvc<T> {
127 type Response = super::ResponsePing;
128 type Future = BoxFuture<
129 tonic::Response<Self::Response>,
130 tonic::Status,
131 >;
132 fn call(
133 &mut self,
134 request: tonic::Request<super::RequestPing>,
135 ) -> Self::Future {
136 let inner = Arc::clone(&self.0);
137 let fut = async move {
138 <T as BroadcastApi>::ping(&inner, request).await
139 };
140 Box::pin(fut)
141 }
142 }
143 let accept_compression_encodings = self.accept_compression_encodings;
144 let send_compression_encodings = self.send_compression_encodings;
145 let max_decoding_message_size = self.max_decoding_message_size;
146 let max_encoding_message_size = self.max_encoding_message_size;
147 let inner = self.inner.clone();
148 let fut = async move {
149 let method = PingSvc(inner);
150 let codec = tonic::codec::ProstCodec::default();
151 let mut grpc = tonic::server::Grpc::new(codec)
152 .apply_compression_config(
153 accept_compression_encodings,
154 send_compression_encodings,
155 )
156 .apply_max_message_size_config(
157 max_decoding_message_size,
158 max_encoding_message_size,
159 );
160 let res = grpc.unary(method, req).await;
161 Ok(res)
162 };
163 Box::pin(fut)
164 }
165 "/tendermint.rpc.grpc.BroadcastAPI/BroadcastTx" => {
166 #[allow(non_camel_case_types)]
167 struct BroadcastTxSvc<T: BroadcastApi>(pub Arc<T>);
168 impl<
169 T: BroadcastApi,
170 > tonic::server::UnaryService<super::RequestBroadcastTx>
171 for BroadcastTxSvc<T> {
172 type Response = super::ResponseBroadcastTx;
173 type Future = BoxFuture<
174 tonic::Response<Self::Response>,
175 tonic::Status,
176 >;
177 fn call(
178 &mut self,
179 request: tonic::Request<super::RequestBroadcastTx>,
180 ) -> Self::Future {
181 let inner = Arc::clone(&self.0);
182 let fut = async move {
183 <T as BroadcastApi>::broadcast_tx(&inner, request).await
184 };
185 Box::pin(fut)
186 }
187 }
188 let accept_compression_encodings = self.accept_compression_encodings;
189 let send_compression_encodings = self.send_compression_encodings;
190 let max_decoding_message_size = self.max_decoding_message_size;
191 let max_encoding_message_size = self.max_encoding_message_size;
192 let inner = self.inner.clone();
193 let fut = async move {
194 let method = BroadcastTxSvc(inner);
195 let codec = tonic::codec::ProstCodec::default();
196 let mut grpc = tonic::server::Grpc::new(codec)
197 .apply_compression_config(
198 accept_compression_encodings,
199 send_compression_encodings,
200 )
201 .apply_max_message_size_config(
202 max_decoding_message_size,
203 max_encoding_message_size,
204 );
205 let res = grpc.unary(method, req).await;
206 Ok(res)
207 };
208 Box::pin(fut)
209 }
210 _ => {
211 Box::pin(async move {
212 Ok(
213 http::Response::builder()
214 .status(200)
215 .header("grpc-status", tonic::Code::Unimplemented as i32)
216 .header(
217 http::header::CONTENT_TYPE,
218 tonic::metadata::GRPC_CONTENT_TYPE,
219 )
220 .body(empty_body())
221 .unwrap(),
222 )
223 })
224 }
225 }
226 }
227 }
228 impl<T: BroadcastApi> Clone for BroadcastApiServer<T> {
229 fn clone(&self) -> Self {
230 let inner = self.inner.clone();
231 Self {
232 inner,
233 accept_compression_encodings: self.accept_compression_encodings,
234 send_compression_encodings: self.send_compression_encodings,
235 max_decoding_message_size: self.max_decoding_message_size,
236 max_encoding_message_size: self.max_encoding_message_size,
237 }
238 }
239 }
240 impl<T: BroadcastApi> tonic::server::NamedService for BroadcastApiServer<T> {
241 const NAME: &'static str = "tendermint.rpc.grpc.BroadcastAPI";
242 }
243}