1#[cfg(feature = "grpc")]
4pub mod query_client {
5 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
6 use tonic::codegen::http::Uri;
7 use tonic::codegen::*;
8 #[derive(Debug, Clone)]
9 pub struct QueryClient<T> {
10 inner: tonic::client::Grpc<T>,
11 }
12 #[cfg(feature = "grpc-transport")]
13 impl QueryClient<tonic::transport::Channel> {
14 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
16 where
17 D: TryInto<tonic::transport::Endpoint>,
18 D::Error: Into<StdError>,
19 {
20 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
21 Ok(Self::new(conn))
22 }
23 }
24 impl<T> QueryClient<T>
25 where
26 T: tonic::client::GrpcService<tonic::body::BoxBody>,
27 T::Error: Into<StdError>,
28 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
29 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
30 {
31 pub fn new(inner: T) -> Self {
32 let inner = tonic::client::Grpc::new(inner);
33 Self { inner }
34 }
35 pub fn with_origin(inner: T, origin: Uri) -> Self {
36 let inner = tonic::client::Grpc::with_origin(inner, origin);
37 Self { inner }
38 }
39 pub fn with_interceptor<F>(
40 inner: T,
41 interceptor: F,
42 ) -> QueryClient<InterceptedService<T, F>>
43 where
44 F: tonic::service::Interceptor,
45 T::ResponseBody: Default,
46 T: tonic::codegen::Service<
47 http::Request<tonic::body::BoxBody>,
48 Response = http::Response<
49 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
50 >,
51 >,
52 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
53 Into<StdError> + Send + Sync,
54 {
55 QueryClient::new(InterceptedService::new(inner, interceptor))
56 }
57 #[must_use]
62 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
63 self.inner = self.inner.send_compressed(encoding);
64 self
65 }
66 #[must_use]
68 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
69 self.inner = self.inner.accept_compressed(encoding);
70 self
71 }
72 #[must_use]
76 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
77 self.inner = self.inner.max_decoding_message_size(limit);
78 self
79 }
80 #[must_use]
84 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
85 self.inner = self.inner.max_encoding_message_size(limit);
86 self
87 }
88 pub async fn params(
89 &mut self,
90 request: impl tonic::IntoRequest<super::QueryParamsRequest>,
91 ) -> core::result::Result<tonic::Response<super::QueryParamsResponse>, tonic::Status>
92 {
93 self.inner.ready().await.map_err(|e| {
94 tonic::Status::new(
95 tonic::Code::Unknown,
96 alloc::format!("Service was not ready: {}", e.into()),
97 )
98 })?;
99 let codec = tonic::codec::ProstCodec::default();
100 let path = http::uri::PathAndQuery::from_static("/bitway.incentive.Query/Params");
101 let mut req = request.into_request();
102 req.extensions_mut()
103 .insert(GrpcMethod::new("bitway.incentive.Query", "Params"));
104 self.inner.unary(req, path, codec).await
105 }
106 pub async fn rewards(
107 &mut self,
108 request: impl tonic::IntoRequest<super::QueryRewardsRequest>,
109 ) -> core::result::Result<tonic::Response<super::QueryRewardsResponse>, tonic::Status>
110 {
111 self.inner.ready().await.map_err(|e| {
112 tonic::Status::new(
113 tonic::Code::Unknown,
114 alloc::format!("Service was not ready: {}", e.into()),
115 )
116 })?;
117 let codec = tonic::codec::ProstCodec::default();
118 let path = http::uri::PathAndQuery::from_static("/bitway.incentive.Query/Rewards");
119 let mut req = request.into_request();
120 req.extensions_mut()
121 .insert(GrpcMethod::new("bitway.incentive.Query", "Rewards"));
122 self.inner.unary(req, path, codec).await
123 }
124 pub async fn reward_stats(
125 &mut self,
126 request: impl tonic::IntoRequest<super::QueryRewardStatsRequest>,
127 ) -> core::result::Result<tonic::Response<super::QueryRewardStatsResponse>, tonic::Status>
128 {
129 self.inner.ready().await.map_err(|e| {
130 tonic::Status::new(
131 tonic::Code::Unknown,
132 alloc::format!("Service was not ready: {}", e.into()),
133 )
134 })?;
135 let codec = tonic::codec::ProstCodec::default();
136 let path = http::uri::PathAndQuery::from_static("/bitway.incentive.Query/RewardStats");
137 let mut req = request.into_request();
138 req.extensions_mut()
139 .insert(GrpcMethod::new("bitway.incentive.Query", "RewardStats"));
140 self.inner.unary(req, path, codec).await
141 }
142 }
143}
144#[cfg(feature = "grpc")]
146pub mod query_server {
147 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
148 use tonic::codegen::*;
149 #[async_trait]
151 pub trait Query: Send + Sync + 'static {
152 async fn params(
153 &self,
154 request: tonic::Request<super::QueryParamsRequest>,
155 ) -> core::result::Result<tonic::Response<super::QueryParamsResponse>, tonic::Status>;
156 async fn rewards(
157 &self,
158 request: tonic::Request<super::QueryRewardsRequest>,
159 ) -> core::result::Result<tonic::Response<super::QueryRewardsResponse>, tonic::Status>;
160 async fn reward_stats(
161 &self,
162 request: tonic::Request<super::QueryRewardStatsRequest>,
163 ) -> core::result::Result<tonic::Response<super::QueryRewardStatsResponse>, tonic::Status>;
164 }
165 #[derive(Debug)]
166 pub struct QueryServer<T: Query> {
167 inner: _Inner<T>,
168 accept_compression_encodings: EnabledCompressionEncodings,
169 send_compression_encodings: EnabledCompressionEncodings,
170 max_decoding_message_size: Option<usize>,
171 max_encoding_message_size: Option<usize>,
172 }
173 struct _Inner<T>(Arc<T>);
174 impl<T: Query> QueryServer<T> {
175 pub fn new(inner: T) -> Self {
176 Self::from_arc(Arc::new(inner))
177 }
178 pub fn from_arc(inner: Arc<T>) -> Self {
179 let inner = _Inner(inner);
180 Self {
181 inner,
182 accept_compression_encodings: Default::default(),
183 send_compression_encodings: Default::default(),
184 max_decoding_message_size: None,
185 max_encoding_message_size: None,
186 }
187 }
188 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
189 where
190 F: tonic::service::Interceptor,
191 {
192 InterceptedService::new(Self::new(inner), interceptor)
193 }
194 #[must_use]
196 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
197 self.accept_compression_encodings.enable(encoding);
198 self
199 }
200 #[must_use]
202 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
203 self.send_compression_encodings.enable(encoding);
204 self
205 }
206 #[must_use]
210 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
211 self.max_decoding_message_size = Some(limit);
212 self
213 }
214 #[must_use]
218 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
219 self.max_encoding_message_size = Some(limit);
220 self
221 }
222 }
223 impl<T, B> tonic::codegen::Service<http::Request<B>> for QueryServer<T>
224 where
225 T: Query,
226 B: Body + Send + 'static,
227 B::Error: Into<StdError> + Send + 'static,
228 {
229 type Response = http::Response<tonic::body::BoxBody>;
230 type Error = std::convert::Infallible;
231 type Future = BoxFuture<Self::Response, Self::Error>;
232 fn poll_ready(
233 &mut self,
234 _cx: &mut Context<'_>,
235 ) -> Poll<core::result::Result<(), Self::Error>> {
236 Poll::Ready(Ok(()))
237 }
238 fn call(&mut self, req: http::Request<B>) -> Self::Future {
239 let inner = self.inner.clone();
240 match req.uri().path() {
241 "/bitway.incentive.Query/Params" => {
242 #[allow(non_camel_case_types)]
243 struct ParamsSvc<T: Query>(pub Arc<T>);
244 impl<T: Query> tonic::server::UnaryService<super::QueryParamsRequest> for ParamsSvc<T> {
245 type Response = super::QueryParamsResponse;
246 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
247 fn call(
248 &mut self,
249 request: tonic::Request<super::QueryParamsRequest>,
250 ) -> Self::Future {
251 let inner = Arc::clone(&self.0);
252 let fut = async move { (*inner).params(request).await };
253 Box::pin(fut)
254 }
255 }
256 let accept_compression_encodings = self.accept_compression_encodings;
257 let send_compression_encodings = self.send_compression_encodings;
258 let max_decoding_message_size = self.max_decoding_message_size;
259 let max_encoding_message_size = self.max_encoding_message_size;
260 let inner = self.inner.clone();
261 let fut = async move {
262 let inner = inner.0;
263 let method = ParamsSvc(inner);
264 let codec = tonic::codec::ProstCodec::default();
265 let mut grpc = tonic::server::Grpc::new(codec)
266 .apply_compression_config(
267 accept_compression_encodings,
268 send_compression_encodings,
269 )
270 .apply_max_message_size_config(
271 max_decoding_message_size,
272 max_encoding_message_size,
273 );
274 let res = grpc.unary(method, req).await;
275 Ok(res)
276 };
277 Box::pin(fut)
278 }
279 "/bitway.incentive.Query/Rewards" => {
280 #[allow(non_camel_case_types)]
281 struct RewardsSvc<T: Query>(pub Arc<T>);
282 impl<T: Query> tonic::server::UnaryService<super::QueryRewardsRequest> for RewardsSvc<T> {
283 type Response = super::QueryRewardsResponse;
284 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
285 fn call(
286 &mut self,
287 request: tonic::Request<super::QueryRewardsRequest>,
288 ) -> Self::Future {
289 let inner = Arc::clone(&self.0);
290 let fut = async move { (*inner).rewards(request).await };
291 Box::pin(fut)
292 }
293 }
294 let accept_compression_encodings = self.accept_compression_encodings;
295 let send_compression_encodings = self.send_compression_encodings;
296 let max_decoding_message_size = self.max_decoding_message_size;
297 let max_encoding_message_size = self.max_encoding_message_size;
298 let inner = self.inner.clone();
299 let fut = async move {
300 let inner = inner.0;
301 let method = RewardsSvc(inner);
302 let codec = tonic::codec::ProstCodec::default();
303 let mut grpc = tonic::server::Grpc::new(codec)
304 .apply_compression_config(
305 accept_compression_encodings,
306 send_compression_encodings,
307 )
308 .apply_max_message_size_config(
309 max_decoding_message_size,
310 max_encoding_message_size,
311 );
312 let res = grpc.unary(method, req).await;
313 Ok(res)
314 };
315 Box::pin(fut)
316 }
317 "/bitway.incentive.Query/RewardStats" => {
318 #[allow(non_camel_case_types)]
319 struct RewardStatsSvc<T: Query>(pub Arc<T>);
320 impl<T: Query> tonic::server::UnaryService<super::QueryRewardStatsRequest> for RewardStatsSvc<T> {
321 type Response = super::QueryRewardStatsResponse;
322 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
323 fn call(
324 &mut self,
325 request: tonic::Request<super::QueryRewardStatsRequest>,
326 ) -> Self::Future {
327 let inner = Arc::clone(&self.0);
328 let fut = async move { (*inner).reward_stats(request).await };
329 Box::pin(fut)
330 }
331 }
332 let accept_compression_encodings = self.accept_compression_encodings;
333 let send_compression_encodings = self.send_compression_encodings;
334 let max_decoding_message_size = self.max_decoding_message_size;
335 let max_encoding_message_size = self.max_encoding_message_size;
336 let inner = self.inner.clone();
337 let fut = async move {
338 let inner = inner.0;
339 let method = RewardStatsSvc(inner);
340 let codec = tonic::codec::ProstCodec::default();
341 let mut grpc = tonic::server::Grpc::new(codec)
342 .apply_compression_config(
343 accept_compression_encodings,
344 send_compression_encodings,
345 )
346 .apply_max_message_size_config(
347 max_decoding_message_size,
348 max_encoding_message_size,
349 );
350 let res = grpc.unary(method, req).await;
351 Ok(res)
352 };
353 Box::pin(fut)
354 }
355 _ => Box::pin(async move {
356 Ok(http::Response::builder()
357 .status(200)
358 .header("grpc-status", "12")
359 .header("content-type", "application/grpc")
360 .body(empty_body())
361 .unwrap())
362 }),
363 }
364 }
365 }
366 impl<T: Query> Clone for QueryServer<T> {
367 fn clone(&self) -> Self {
368 let inner = self.inner.clone();
369 Self {
370 inner,
371 accept_compression_encodings: self.accept_compression_encodings,
372 send_compression_encodings: self.send_compression_encodings,
373 max_decoding_message_size: self.max_decoding_message_size,
374 max_encoding_message_size: self.max_encoding_message_size,
375 }
376 }
377 }
378 impl<T: Query> Clone for _Inner<T> {
379 fn clone(&self) -> Self {
380 Self(Arc::clone(&self.0))
381 }
382 }
383 impl<T: core::fmt::Debug> core::fmt::Debug for _Inner<T> {
384 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
385 write!(f, "{:?}", self.0)
386 }
387 }
388 impl<T: Query> tonic::server::NamedService for QueryServer<T> {
389 const NAME: &'static str = "bitway.incentive.Query";
390 }
391}
392#[cfg(feature = "grpc")]
394pub mod msg_client {
395 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
396 use tonic::codegen::http::Uri;
397 use tonic::codegen::*;
398 #[derive(Debug, Clone)]
399 pub struct MsgClient<T> {
400 inner: tonic::client::Grpc<T>,
401 }
402 #[cfg(feature = "grpc-transport")]
403 impl MsgClient<tonic::transport::Channel> {
404 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
406 where
407 D: TryInto<tonic::transport::Endpoint>,
408 D::Error: Into<StdError>,
409 {
410 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
411 Ok(Self::new(conn))
412 }
413 }
414 impl<T> MsgClient<T>
415 where
416 T: tonic::client::GrpcService<tonic::body::BoxBody>,
417 T::Error: Into<StdError>,
418 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
419 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
420 {
421 pub fn new(inner: T) -> Self {
422 let inner = tonic::client::Grpc::new(inner);
423 Self { inner }
424 }
425 pub fn with_origin(inner: T, origin: Uri) -> Self {
426 let inner = tonic::client::Grpc::with_origin(inner, origin);
427 Self { inner }
428 }
429 pub fn with_interceptor<F>(inner: T, interceptor: F) -> MsgClient<InterceptedService<T, F>>
430 where
431 F: tonic::service::Interceptor,
432 T::ResponseBody: Default,
433 T: tonic::codegen::Service<
434 http::Request<tonic::body::BoxBody>,
435 Response = http::Response<
436 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
437 >,
438 >,
439 <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
440 Into<StdError> + Send + Sync,
441 {
442 MsgClient::new(InterceptedService::new(inner, interceptor))
443 }
444 #[must_use]
449 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
450 self.inner = self.inner.send_compressed(encoding);
451 self
452 }
453 #[must_use]
455 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
456 self.inner = self.inner.accept_compressed(encoding);
457 self
458 }
459 #[must_use]
463 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
464 self.inner = self.inner.max_decoding_message_size(limit);
465 self
466 }
467 #[must_use]
471 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
472 self.inner = self.inner.max_encoding_message_size(limit);
473 self
474 }
475 pub async fn update_params(
476 &mut self,
477 request: impl tonic::IntoRequest<super::MsgUpdateParams>,
478 ) -> core::result::Result<tonic::Response<super::MsgUpdateParamsResponse>, tonic::Status>
479 {
480 self.inner.ready().await.map_err(|e| {
481 tonic::Status::new(
482 tonic::Code::Unknown,
483 alloc::format!("Service was not ready: {}", e.into()),
484 )
485 })?;
486 let codec = tonic::codec::ProstCodec::default();
487 let path = http::uri::PathAndQuery::from_static("/bitway.incentive.Msg/UpdateParams");
488 let mut req = request.into_request();
489 req.extensions_mut()
490 .insert(GrpcMethod::new("bitway.incentive.Msg", "UpdateParams"));
491 self.inner.unary(req, path, codec).await
492 }
493 }
494}
495#[cfg(feature = "grpc")]
497pub mod msg_server {
498 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
499 use tonic::codegen::*;
500 #[async_trait]
502 pub trait Msg: Send + Sync + 'static {
503 async fn update_params(
504 &self,
505 request: tonic::Request<super::MsgUpdateParams>,
506 ) -> core::result::Result<tonic::Response<super::MsgUpdateParamsResponse>, tonic::Status>;
507 }
508 #[derive(Debug)]
509 pub struct MsgServer<T: Msg> {
510 inner: _Inner<T>,
511 accept_compression_encodings: EnabledCompressionEncodings,
512 send_compression_encodings: EnabledCompressionEncodings,
513 max_decoding_message_size: Option<usize>,
514 max_encoding_message_size: Option<usize>,
515 }
516 struct _Inner<T>(Arc<T>);
517 impl<T: Msg> MsgServer<T> {
518 pub fn new(inner: T) -> Self {
519 Self::from_arc(Arc::new(inner))
520 }
521 pub fn from_arc(inner: Arc<T>) -> Self {
522 let inner = _Inner(inner);
523 Self {
524 inner,
525 accept_compression_encodings: Default::default(),
526 send_compression_encodings: Default::default(),
527 max_decoding_message_size: None,
528 max_encoding_message_size: None,
529 }
530 }
531 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
532 where
533 F: tonic::service::Interceptor,
534 {
535 InterceptedService::new(Self::new(inner), interceptor)
536 }
537 #[must_use]
539 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
540 self.accept_compression_encodings.enable(encoding);
541 self
542 }
543 #[must_use]
545 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
546 self.send_compression_encodings.enable(encoding);
547 self
548 }
549 #[must_use]
553 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
554 self.max_decoding_message_size = Some(limit);
555 self
556 }
557 #[must_use]
561 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
562 self.max_encoding_message_size = Some(limit);
563 self
564 }
565 }
566 impl<T, B> tonic::codegen::Service<http::Request<B>> for MsgServer<T>
567 where
568 T: Msg,
569 B: Body + Send + 'static,
570 B::Error: Into<StdError> + Send + 'static,
571 {
572 type Response = http::Response<tonic::body::BoxBody>;
573 type Error = std::convert::Infallible;
574 type Future = BoxFuture<Self::Response, Self::Error>;
575 fn poll_ready(
576 &mut self,
577 _cx: &mut Context<'_>,
578 ) -> Poll<core::result::Result<(), Self::Error>> {
579 Poll::Ready(Ok(()))
580 }
581 fn call(&mut self, req: http::Request<B>) -> Self::Future {
582 let inner = self.inner.clone();
583 match req.uri().path() {
584 "/bitway.incentive.Msg/UpdateParams" => {
585 #[allow(non_camel_case_types)]
586 struct UpdateParamsSvc<T: Msg>(pub Arc<T>);
587 impl<T: Msg> tonic::server::UnaryService<super::MsgUpdateParams> for UpdateParamsSvc<T> {
588 type Response = super::MsgUpdateParamsResponse;
589 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
590 fn call(
591 &mut self,
592 request: tonic::Request<super::MsgUpdateParams>,
593 ) -> Self::Future {
594 let inner = Arc::clone(&self.0);
595 let fut = async move { (*inner).update_params(request).await };
596 Box::pin(fut)
597 }
598 }
599 let accept_compression_encodings = self.accept_compression_encodings;
600 let send_compression_encodings = self.send_compression_encodings;
601 let max_decoding_message_size = self.max_decoding_message_size;
602 let max_encoding_message_size = self.max_encoding_message_size;
603 let inner = self.inner.clone();
604 let fut = async move {
605 let inner = inner.0;
606 let method = UpdateParamsSvc(inner);
607 let codec = tonic::codec::ProstCodec::default();
608 let mut grpc = tonic::server::Grpc::new(codec)
609 .apply_compression_config(
610 accept_compression_encodings,
611 send_compression_encodings,
612 )
613 .apply_max_message_size_config(
614 max_decoding_message_size,
615 max_encoding_message_size,
616 );
617 let res = grpc.unary(method, req).await;
618 Ok(res)
619 };
620 Box::pin(fut)
621 }
622 _ => Box::pin(async move {
623 Ok(http::Response::builder()
624 .status(200)
625 .header("grpc-status", "12")
626 .header("content-type", "application/grpc")
627 .body(empty_body())
628 .unwrap())
629 }),
630 }
631 }
632 }
633 impl<T: Msg> Clone for MsgServer<T> {
634 fn clone(&self) -> Self {
635 let inner = self.inner.clone();
636 Self {
637 inner,
638 accept_compression_encodings: self.accept_compression_encodings,
639 send_compression_encodings: self.send_compression_encodings,
640 max_decoding_message_size: self.max_decoding_message_size,
641 max_encoding_message_size: self.max_encoding_message_size,
642 }
643 }
644 }
645 impl<T: Msg> Clone for _Inner<T> {
646 fn clone(&self) -> Self {
647 Self(Arc::clone(&self.0))
648 }
649 }
650 impl<T: core::fmt::Debug> core::fmt::Debug for _Inner<T> {
651 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
652 write!(f, "{:?}", self.0)
653 }
654 }
655 impl<T: Msg> tonic::server::NamedService for MsgServer<T> {
656 const NAME: &'static str = "bitway.incentive.Msg";
657 }
658}