Skip to content

Commit

Permalink
proto: regen
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Batschelet <[email protected]>
  • Loading branch information
hexfusion committed Sep 5, 2023
1 parent 8e2d812 commit 5a669d2
Show file tree
Hide file tree
Showing 26 changed files with 5,721 additions and 2,706 deletions.
2 changes: 1 addition & 1 deletion crates/avalanche-types/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pub mod pb;
pub use pb::*;

/// ref. <https://github.com/ava-labs/avalanchego/blob/v1.10.1/version/constants.go#L15-L17>
pub const PROTOCOL_VERSION: u32 = 26;
pub const PROTOCOL_VERSION: u32 = 28;
95 changes: 80 additions & 15 deletions crates/avalanche-types/src/proto/pb/aliasreader.tonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod alias_reader_client {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Expand Down Expand Up @@ -68,10 +68,26 @@ pub mod alias_reader_client {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn lookup(
&mut self,
request: impl tonic::IntoRequest<super::Alias>,
) -> Result<tonic::Response<super::Id>, tonic::Status> {
) -> std::result::Result<tonic::Response<super::Id>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -85,12 +101,15 @@ pub mod alias_reader_client {
let path = http::uri::PathAndQuery::from_static(
"/aliasreader.AliasReader/Lookup",
);
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("aliasreader.AliasReader", "Lookup"));
self.inner.unary(req, path, codec).await
}
pub async fn primary_alias(
&mut self,
request: impl tonic::IntoRequest<super::Id>,
) -> Result<tonic::Response<super::Alias>, tonic::Status> {
) -> std::result::Result<tonic::Response<super::Alias>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -104,12 +123,15 @@ pub mod alias_reader_client {
let path = http::uri::PathAndQuery::from_static(
"/aliasreader.AliasReader/PrimaryAlias",
);
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("aliasreader.AliasReader", "PrimaryAlias"));
self.inner.unary(req, path, codec).await
}
pub async fn aliases(
&mut self,
request: impl tonic::IntoRequest<super::Id>,
) -> Result<tonic::Response<super::AliasList>, tonic::Status> {
) -> std::result::Result<tonic::Response<super::AliasList>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -123,7 +145,10 @@ pub mod alias_reader_client {
let path = http::uri::PathAndQuery::from_static(
"/aliasreader.AliasReader/Aliases",
);
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("aliasreader.AliasReader", "Aliases"));
self.inner.unary(req, path, codec).await
}
}
}
Expand All @@ -137,21 +162,23 @@ pub mod alias_reader_server {
async fn lookup(
&self,
request: tonic::Request<super::Alias>,
) -> Result<tonic::Response<super::Id>, tonic::Status>;
) -> std::result::Result<tonic::Response<super::Id>, tonic::Status>;
async fn primary_alias(
&self,
request: tonic::Request<super::Id>,
) -> Result<tonic::Response<super::Alias>, tonic::Status>;
) -> std::result::Result<tonic::Response<super::Alias>, tonic::Status>;
async fn aliases(
&self,
request: tonic::Request<super::Id>,
) -> Result<tonic::Response<super::AliasList>, tonic::Status>;
) -> std::result::Result<tonic::Response<super::AliasList>, tonic::Status>;
}
#[derive(Debug)]
pub struct AliasReaderServer<T: AliasReader> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: AliasReader> AliasReaderServer<T> {
Expand All @@ -164,6 +191,8 @@ pub mod alias_reader_server {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
Expand All @@ -187,6 +216,22 @@ pub mod alias_reader_server {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for AliasReaderServer<T>
where
Expand All @@ -200,7 +245,7 @@ pub mod alias_reader_server {
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
Expand All @@ -220,13 +265,15 @@ pub mod alias_reader_server {
&mut self,
request: tonic::Request<super::Alias>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).lookup(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
Expand All @@ -236,6 +283,10 @@ pub mod alias_reader_server {
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
Expand All @@ -256,7 +307,7 @@ pub mod alias_reader_server {
&mut self,
request: tonic::Request<super::Id>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move {
(*inner).primary_alias(request).await
};
Expand All @@ -265,6 +316,8 @@ pub mod alias_reader_server {
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
Expand All @@ -274,6 +327,10 @@ pub mod alias_reader_server {
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
Expand All @@ -294,13 +351,15 @@ pub mod alias_reader_server {
&mut self,
request: tonic::Request<super::Id>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).aliases(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
Expand All @@ -310,6 +369,10 @@ pub mod alias_reader_server {
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
Expand Down Expand Up @@ -338,12 +401,14 @@ pub mod alias_reader_server {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
impl<T: AliasReader> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
Expand Down
Loading

0 comments on commit 5a669d2

Please sign in to comment.