From df8328be09baeb81b7aaa037022eedaa7a416598 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 18 Jan 2021 17:33:39 -0500 Subject: set larger default maximum message size (fix issue #15) --- examples/hotstuff_client.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/hotstuff_client.cpp b/examples/hotstuff_client.cpp index 831b7ff..fc406d6 100644 --- a/examples/hotstuff_client.cpp +++ b/examples/hotstuff_client.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -63,11 +64,11 @@ std::unordered_map conns; std::unordered_map waiting; std::vector replicas; std::vector> elapsed; -Net mn(ec, Net::Config()); +std::unique_ptr mn; void connect_all() { for (size_t i = 0; i < replicas.size(); i++) - conns.insert(std::make_pair(i, mn.connect_sync(replicas[i]))); + conns.insert(std::make_pair(i, mn->connect_sync(replicas[i]))); } bool try_send(bool check = true) { @@ -75,7 +76,7 @@ bool try_send(bool check = true) { { auto cmd = new CommandDummy(cid, cnt++); MsgReqCmd msg(*cmd); - for (auto &p: conns) mn.send_msg(msg, p.second); + for (auto &p: conns) mn->send_msg(msg, p.second); #ifndef HOTSTUFF_ENABLE_BENCHMARK HOTSTUFF_LOG_INFO("send new cmd %.10s", get_hex(cmd->get_hash()).c_str()); @@ -124,6 +125,7 @@ int main(int argc, char **argv) { auto opt_max_iter_num = Config::OptValInt::create(100); auto opt_max_async_num = Config::OptValInt::create(10); auto opt_cid = Config::OptValInt::create(-1); + auto opt_max_cli_msg = Config::OptValInt::create(65536); // 64K by default auto shutdown = [&](int) { ec.stop(); }; salticidae::SigEvent ev_sigint(ec, shutdown); @@ -131,14 +133,16 @@ int main(int argc, char **argv) { ev_sigint.add(SIGINT); ev_sigterm.add(SIGTERM); - mn.reg_handler(client_resp_cmd_handler); - mn.start(); + mn = std::make_unique(ec, Net::Config().max_msg_size(opt_max_cli_msg->get())); + mn->reg_handler(client_resp_cmd_handler); + mn->start(); config.add_opt("idx", opt_idx, Config::SET_VAL); config.add_opt("cid", opt_cid, Config::SET_VAL); config.add_opt("replica", opt_replicas, Config::APPEND); config.add_opt("iter", opt_max_iter_num, Config::SET_VAL); config.add_opt("max-async", opt_max_async_num, Config::SET_VAL); + config.add_opt("max-cli-msg", opt_max_cli_msg, Config::SET_VAL, 'S', "the maximum client message size"); config.parse(argc, argv); auto idx = opt_idx->get(); max_iter_num = opt_max_iter_num->get(); -- cgit v1.2.3-70-g09d2