diff --git a/tap_aggregator/Cargo.toml b/tap_aggregator/Cargo.toml index 9a92d9a..0e85c6d 100644 --- a/tap_aggregator/Cargo.toml +++ b/tap_aggregator/Cargo.toml @@ -36,6 +36,7 @@ futures-util = "0.3.28" lazy_static = "1.4.0" ruint = "1.10.1" tower = { version = "0.4", features = ["util"] } +tower-http = { version = "0.6.1", features = ["decompression-zstd"]} [dev-dependencies] jsonrpsee = { workspace = true, features = ["http-client", "jsonrpsee-core"] } diff --git a/tap_aggregator/src/server.rs b/tap_aggregator/src/server.rs index 0ff03d3..2ecbbcd 100644 --- a/tap_aggregator/src/server.rs +++ b/tap_aggregator/src/server.rs @@ -10,6 +10,8 @@ use anyhow::Result; use jsonrpsee::{proc_macros::rpc, server::ServerBuilder, server::ServerHandle}; use lazy_static::lazy_static; use prometheus::{register_counter, register_int_counter, Counter, IntCounter}; +use tower::{Layer, ServiceBuilder}; +use tower_http::decompression::RequestDecompressionLayer; use crate::aggregator::check_and_aggregate_receipts; use crate::api_versioning::{ @@ -217,12 +219,15 @@ pub async fn run_server( max_response_body_size: u32, max_concurrent_connections: u32, ) -> Result<(ServerHandle, std::net::SocketAddr)> { + let http_middleware = ServiceBuilder::new().layer(RequestDecompressionLayer::new().zstd(true)); + // Setting up the JSON RPC server println!("Starting server..."); let server = ServerBuilder::new() .max_request_body_size(max_request_body_size) .max_response_body_size(max_response_body_size) .max_connections(max_concurrent_connections) + .set_http_middleware(http_middleware) .http_only() .build(format!("0.0.0.0:{}", port)) .await?;