Skip to content

Commit

Permalink
Support for boost 1.70 in load tester (#2034)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocode authored May 27, 2019
1 parent 74b6eaf commit af04b5a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions nano/load_test/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
#include <iomanip>
#include <random>

/* Boost v1.70 introduced breaking changes; the conditional compilation allows 1.6x to be supported as well. */
#if BOOST_VERSION < 107000
using socket_type = boost::asio::ip::tcp::socket;
#else
using socket_type = boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::executor_type>;
#endif

namespace nano
{
void force_nano_test_network ();
Expand Down Expand Up @@ -149,7 +156,7 @@ class receive_session final : public std::enable_shared_from_this<receive_sessio
}

private:
tcp::socket socket;
socket_type socket;
boost::asio::strand<boost::asio::io_context::executor_type> strand;
boost::beast::flat_buffer buffer;
http::request<http::string_body> req;
Expand All @@ -165,6 +172,7 @@ class send_session final : public std::enable_shared_from_this<send_session>
{
public:
send_session (boost::asio::io_context & ioc, std::atomic<int> & send_calls_remaining, std::string const & wallet, std::string const & source, std::string const & destination, tcp::resolver::results_type const & results) :
io_ctx (ioc),
socket (ioc),
strand (socket.get_executor ()),
send_calls_remaining (send_calls_remaining),
Expand Down Expand Up @@ -217,7 +225,7 @@ class send_session final : public std::enable_shared_from_this<send_session>
boost::property_tree::read_json (body, json);
auto block = json.get<std::string> ("block");

std::make_shared<receive_session> (this_l->socket.get_io_context (), this_l->send_calls_remaining, this_l->wallet, this_l->destination, block, this_l->results)->run ();
std::make_shared<receive_session> (this_l->io_ctx, this_l->send_calls_remaining, this_l->wallet, this_l->destination, block, this_l->results)->run ();

this_l->socket.shutdown (tcp::socket::shutdown_both, ec);
if (ec && ec != boost::system::errc::not_connected)
Expand All @@ -230,7 +238,8 @@ class send_session final : public std::enable_shared_from_this<send_session>
}

private:
tcp::socket socket;
boost::asio::io_context & io_ctx;
socket_type socket;
boost::asio::strand<boost::asio::io_context::executor_type> strand;
boost::beast::flat_buffer buffer;
http::request<http::string_body> req;
Expand Down

0 comments on commit af04b5a

Please sign in to comment.