From 831e84940df56eefc432caccaceb96622cdee1bb Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 14 Mar 2024 11:20:23 +0000 Subject: [PATCH] make fmt --- silkworm/rpc/http/connection.cpp | 69 +++++++++++++++----------------- silkworm/rpc/http/connection.hpp | 2 +- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/silkworm/rpc/http/connection.cpp b/silkworm/rpc/http/connection.cpp index f20e71cdea..369a8febb2 100644 --- a/silkworm/rpc/http/connection.cpp +++ b/silkworm/rpc/http/connection.cpp @@ -16,12 +16,12 @@ #include "connection.hpp" +#include + #include #include #include -#include - #include #include #include @@ -194,10 +194,10 @@ Task Connection::handle_actual_request(const boost::beast::http::request= 0) { auto rsp_content = co_await request_handler_.handle(clear_data); @@ -207,7 +207,6 @@ Task Connection::handle_actual_request(const boost::beast::http::requestappend("\n"), boost::beast::http::status::ok); @@ -287,7 +286,7 @@ Task Connection::do_write(const std::string& content, boost::beast::http:: std::cout << "AcceptEncoding: " << coded << "\n"; res.set(boost::beast::http::field::content_encoding, coded); std::string coded_data; - coded_data.resize(10*1024*1024); + coded_data.resize(10 * 1024 * 1024); auto ret = compress_data(content, coded_data); if (ret >= 0) { res.content_length(coded_data.size()); @@ -319,69 +318,65 @@ Task Connection::do_write(const std::string& content, boost::beast::http:: long Connection::compress_data(std::string clear_data, std::string compressed_data) { z_stream strm; - strm.zalloc=nullptr; - strm.zfree=nullptr; - strm.opaque=nullptr; + strm.zalloc = nullptr; + strm.zfree = nullptr; + strm.opaque = nullptr; strm.avail_in = static_cast(clear_data.size()); strm.avail_out = static_cast(compressed_data.size()); - auto ptr_clear = const_cast (clear_data.c_str()); - strm.next_in = reinterpret_cast (ptr_clear); + auto ptr_clear = const_cast(clear_data.c_str()); + strm.next_in = reinterpret_cast(ptr_clear); - auto ptr_coded = const_cast (compressed_data.c_str()); - strm.next_out = reinterpret_cast (ptr_coded); + auto ptr_coded = const_cast(compressed_data.c_str()); + strm.next_out = reinterpret_cast(ptr_coded); - int err=Z_OK; - err = inflateInit2(&strm, MAX_WBITS+16); - if (err == Z_OK){ + int err = Z_OK; + err = inflateInit2(&strm, MAX_WBITS + 16); + if (err == Z_OK) { err = inflate(&strm, Z_FINISH); - if (err == Z_STREAM_END){ + if (err == Z_STREAM_END) { auto ret = strm.total_out; inflateEnd(&strm); return static_cast(ret); - } - else{ + } else { inflateEnd(&strm); return err; } - } - else{ + } else { inflateEnd(&strm); return err; } } -long Connection::uncompress_data(std::string compressed_data, std::string clear_data){ +long Connection::uncompress_data(std::string compressed_data, std::string clear_data) { z_stream strm; - strm.zalloc=nullptr; - strm.zfree=nullptr; - strm.opaque=nullptr; + strm.zalloc = nullptr; + strm.zfree = nullptr; + strm.opaque = nullptr; strm.avail_in = static_cast(compressed_data.size()); strm.avail_out = static_cast(clear_data.size()); - auto ptr_coded = const_cast (compressed_data.c_str()); - strm.next_in = reinterpret_cast (ptr_coded); + auto ptr_coded = const_cast(compressed_data.c_str()); + strm.next_in = reinterpret_cast(ptr_coded); - auto ptr_clear = const_cast (clear_data.c_str()); - strm.next_out = reinterpret_cast (ptr_clear); + auto ptr_clear = const_cast(clear_data.c_str()); + strm.next_out = reinterpret_cast(ptr_clear); - int err=Z_OK; - err = deflateInit(&strm, MAX_WBITS+16); - if (err == Z_OK){ + int err = Z_OK; + err = deflateInit(&strm, MAX_WBITS + 16); + if (err == Z_OK) { err = deflate(&strm, Z_FINISH); - if (err == Z_STREAM_END){ + if (err == Z_STREAM_END) { auto ret = strm.total_out; inflateEnd(&strm); return static_cast(ret); - } - else{ + } else { inflateEnd(&strm); return err; } - } - else{ + } else { inflateEnd(&strm); return err; } diff --git a/silkworm/rpc/http/connection.hpp b/silkworm/rpc/http/connection.hpp index e27132211c..e1095f32e0 100644 --- a/silkworm/rpc/http/connection.hpp +++ b/silkworm/rpc/http/connection.hpp @@ -86,7 +86,7 @@ class Connection : public StreamWriter { Task do_read(); //! Perform an asynchronous write operation. - Task do_write(const std::string& content, boost::beast::http::status http_status, bool compress=false); + Task do_write(const std::string& content, boost::beast::http::status http_status, bool compress = false); static std::string get_date_time();