From 950559b5aa0b3ed1d7703ab51f6aa975ca56d088 Mon Sep 17 00:00:00 2001 From: godmodegalactus Date: Mon, 22 Apr 2024 18:48:17 +0200 Subject: [PATCH] Adding tonic with gzip feature --- Cargo.lock | 2 ++ Cargo.toml | 1 + src/yellowstone_grpc_util.rs | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index db5b86b..592cc0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1264,6 +1264,7 @@ dependencies = [ "solana-logger", "solana-sdk", "tokio", + "tonic", "tonic-health", "tracing", "tracing-subscriber", @@ -3628,6 +3629,7 @@ dependencies = [ "axum", "base64 0.21.7", "bytes", + "flate2", "h2", "http", "http-body", diff --git a/Cargo.toml b/Cargo.toml index bf2c8bb..a26eac7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ bincode = "1.3.3" csv = "1.3.0" +tonic = { version="0.10.2", features=["gzip"] } tonic-health = "0.10.2" [dev-dependencies] diff --git a/src/yellowstone_grpc_util.rs b/src/yellowstone_grpc_util.rs index a2ae11d..1af9680 100644 --- a/src/yellowstone_grpc_util.rs +++ b/src/yellowstone_grpc_util.rs @@ -5,6 +5,7 @@ use yellowstone_grpc_proto::geyser::geyser_client::GeyserClient; use yellowstone_grpc_proto::geyser::SubscribeRequest; use yellowstone_grpc_proto::prost::bytes::Bytes; use yellowstone_grpc_proto::tonic; +use tonic::codec::CompressionEncoding; use yellowstone_grpc_proto::tonic::metadata::errors::InvalidMetadataValue; use yellowstone_grpc_proto::tonic::metadata::AsciiMetadataValue; use yellowstone_grpc_proto::tonic::service::Interceptor; @@ -87,7 +88,9 @@ where let client = GeyserGrpcClient::new( HealthClient::with_interceptor(channel.clone(), interceptor.clone()), GeyserClient::with_interceptor(channel, interceptor) - .max_decoding_message_size(GeyserGrpcClient::max_decoding_message_size()), + .max_decoding_message_size(GeyserGrpcClient::max_decoding_message_size()) + .accept_compressed(CompressionEncoding::Gzip) + .send_compressed(CompressionEncoding::Gzip), ); Ok(client) }