aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2021-01-18 17:33:39 -0500
committerDeterminant <tederminant@gmail.com>2021-01-18 17:33:39 -0500
commitdf8328be09baeb81b7aaa037022eedaa7a416598 (patch)
tree3e6bd8daa8d7bb51efa1f5396b92ddcb54303b58
parentd71b0a01855e881af30f053c1acd89314420bd7b (diff)
set larger default maximum message size (fix issue #15)HEADmaster
-rw-r--r--examples/hotstuff_client.cpp14
1 files 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 <cassert>
#include <random>
+#include <memory>
#include <signal.h>
#include <sys/time.h>
@@ -63,11 +64,11 @@ std::unordered_map<ReplicaID, Net::conn_t> conns;
std::unordered_map<const uint256_t, Request> waiting;
std::vector<NetAddr> replicas;
std::vector<std::pair<struct timeval, double>> elapsed;
-Net mn(ec, Net::Config());
+std::unique_ptr<Net> 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<Net>(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();