Update the websocketpp library and change the configuration options we pass
when creating the websocket servers to enable deflate compression on websocket frames. This is relevant to cryptonomex/graphene#540 because the spammed data is higly compressible. In my tests, it reduces bandwidth for a single idle node by a factor of ~16, from 577kbps down to 36kbps. This doesn't require any changes to the wallets, simply upgrading the public servers will begin sending compressed data to all clients that support it. Note: this commit adds a dependency on zlib for non-apple platforms (it was already required on apple)
This commit is contained in:
parent
38419164b6
commit
d5370fc2ea
3 changed files with 29 additions and 54 deletions
|
|
@ -142,6 +142,17 @@ find_package(OpenSSL REQUIRED)
|
|||
|
||||
set( CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_LIB_SUFFIXES} )
|
||||
|
||||
# We are now building in support for deflate compression into our websockets layer by default,
|
||||
# which requires zlib. Aside from that, all of fc compiles without zlib, so this could be
|
||||
# made optional without much effort
|
||||
# (important exception, apple: as of 10.10 yosemite, the OpenSSL static libraries shipped with
|
||||
# os x have a dependency on zlib)
|
||||
# On a side note, fc's fc::zlib_compress() function uses a separate implementation of zlib
|
||||
# from the miniz library. If we're comfortable requiring an external zlib, we can
|
||||
# reimplement fc::zlib_compress() to call the real zlib, and remove miniz.c from our
|
||||
# repository.
|
||||
find_package( ZLIB REQUIRED )
|
||||
|
||||
option( UNITY_BUILD OFF )
|
||||
|
||||
set( fc_sources
|
||||
|
|
@ -473,14 +484,6 @@ if(WIN32)
|
|||
|
||||
endif(WIN32)
|
||||
|
||||
IF(APPLE)
|
||||
# As of 10.10 yosemite, the OpenSSL static libraries shipped with os x have a dependency
|
||||
# on zlib, so any time you link in openssl you also need to link zlib. . We really want to detect whether openssl was configured with the --no-zlib
|
||||
# option or not when it was built, but that's difficult to do in practice, so we
|
||||
# just always try to link it in on mac.
|
||||
find_package( ZLIB REQUIRED )
|
||||
ENDIF(APPLE)
|
||||
|
||||
SET(OPENSSL_CONF_TARGET )
|
||||
IF(DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
SET (OPENSSL_CONF_TARGET ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <websocketpp/config/asio.hpp>
|
||||
#include <websocketpp/server.hpp>
|
||||
#include <websocketpp/config/asio_client.hpp>
|
||||
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
|
||||
#include <websocketpp/client.hpp>
|
||||
#include <websocketpp/logger/stub.hpp>
|
||||
|
||||
|
|
@ -61,47 +62,12 @@ namespace fc { namespace http {
|
|||
transport_type;
|
||||
|
||||
static const long timeout_open_handshake = 0;
|
||||
};
|
||||
struct asio_tls_with_stub_log : public websocketpp::config::asio_tls {
|
||||
|
||||
typedef asio_with_stub_log type;
|
||||
typedef asio_tls base;
|
||||
/// permessage_compress extension
|
||||
struct permessage_deflate_config {};
|
||||
|
||||
typedef base::concurrency_type concurrency_type;
|
||||
|
||||
typedef base::request_type request_type;
|
||||
typedef base::response_type response_type;
|
||||
|
||||
typedef base::message_type message_type;
|
||||
typedef base::con_msg_manager_type con_msg_manager_type;
|
||||
typedef base::endpoint_msg_manager_type endpoint_msg_manager_type;
|
||||
|
||||
/// Custom Logging policies
|
||||
/*typedef websocketpp::log::syslog<concurrency_type,
|
||||
websocketpp::log::elevel> elog_type;
|
||||
typedef websocketpp::log::syslog<concurrency_type,
|
||||
websocketpp::log::alevel> alog_type;
|
||||
*/
|
||||
//typedef base::alog_type alog_type;
|
||||
//typedef base::elog_type elog_type;
|
||||
typedef websocketpp::log::stub elog_type;
|
||||
typedef websocketpp::log::stub alog_type;
|
||||
|
||||
typedef base::rng_type rng_type;
|
||||
|
||||
struct transport_config : public base::transport_config {
|
||||
typedef type::concurrency_type concurrency_type;
|
||||
typedef type::alog_type alog_type;
|
||||
typedef type::elog_type elog_type;
|
||||
typedef type::request_type request_type;
|
||||
typedef type::response_type response_type;
|
||||
typedef websocketpp::transport::asio::tls_socket::endpoint socket_type;
|
||||
};
|
||||
|
||||
typedef websocketpp::transport::asio::endpoint<transport_config>
|
||||
transport_type;
|
||||
|
||||
static const long timeout_open_handshake = 0;
|
||||
typedef websocketpp::extensions::permessage_deflate::enabled
|
||||
<permessage_deflate_config> permessage_deflate_type;
|
||||
};
|
||||
struct asio_tls_stub_log : public websocketpp::config::asio_tls {
|
||||
typedef asio_tls_stub_log type;
|
||||
|
|
@ -124,16 +90,22 @@ namespace fc { namespace http {
|
|||
typedef base::rng_type rng_type;
|
||||
|
||||
struct transport_config : public base::transport_config {
|
||||
typedef type::concurrency_type concurrency_type;
|
||||
typedef type::alog_type alog_type;
|
||||
typedef type::elog_type elog_type;
|
||||
typedef type::request_type request_type;
|
||||
typedef type::response_type response_type;
|
||||
typedef websocketpp::transport::asio::tls_socket::endpoint socket_type;
|
||||
typedef type::concurrency_type concurrency_type;
|
||||
typedef type::alog_type alog_type;
|
||||
typedef type::elog_type elog_type;
|
||||
typedef type::request_type request_type;
|
||||
typedef type::response_type response_type;
|
||||
typedef websocketpp::transport::asio::tls_socket::endpoint socket_type;
|
||||
};
|
||||
|
||||
typedef websocketpp::transport::asio::endpoint<transport_config>
|
||||
transport_type;
|
||||
|
||||
/// permessage_compress extension
|
||||
struct permessage_deflate_config {};
|
||||
|
||||
typedef websocketpp::extensions::permessage_deflate::enabled
|
||||
<permessage_deflate_config> permessage_deflate_type;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
2
vendor/websocketpp
vendored
2
vendor/websocketpp
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit c5510d6de04917812b910a8dd44735c1f17061d9
|
||||
Subproject commit 378437aecdcb1dfe62096ffd5d944bf1f640ccc3
|
||||
Loading…
Reference in a new issue