aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2018-09-07 21:50:19 -0400
committerDeterminant <ted.sybil@gmail.com>2018-09-07 21:50:19 -0400
commit82d041d9f7881fa23e2999dad636eedaa20217a5 (patch)
tree333d9ec9a6a8c5ba4be6ad3908d192983115f697 /src
parent05f2c56b909a2cd05a200ad663001696e4a23261 (diff)
create new branch alt-cli
Diffstat (limited to 'src')
-rw-r--r--src/hotstuff_client.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/hotstuff_client.cpp b/src/hotstuff_client.cpp
index 62b13ed..31c6c0a 100644
--- a/src/hotstuff_client.cpp
+++ b/src/hotstuff_client.cpp
@@ -1,5 +1,6 @@
#include <cassert>
#include <random>
+#include <signal.h>
#include "salticidae/type.h"
#include "salticidae/netaddr.h"
#include "salticidae/network.h"
@@ -42,6 +43,7 @@ struct Request {
std::unordered_map<ReplicaID, MsgNetwork<opcode_t>::conn_t> conns;
std::unordered_map<const uint256_t, Request> waiting;
std::vector<NetAddr> replicas;
+std::vector<std::pair<struct timeval, double>> elapsed;
MsgNetwork<opcode_t> mn(eb, 10, 10, 4096);
void set_proposer(ReplicaID rid) {
@@ -97,7 +99,10 @@ void client_resp_cmd_handler(MsgRespCmd &&msg, MsgNetwork<opcode_t>::Conn &) {
std::string(fin).c_str(),
et.elapsed_sec, et.cpu_elapsed_sec);
#else
- HOTSTUFF_LOG_INFO("%.6f %.6f", et.elapsed_sec, et.cpu_elapsed_sec);
+ struct timeval tv;
+ gettimeofday(&tv, nullptr);
+ elapsed.push_back(std::make_pair(tv, et.elapsed_sec));
+ //HOTSTUFF_LOG_INFO("%.6f %.6f", et.elapsed_sec, et.cpu_elapsed_sec);
#endif
waiting.erase(it);
try_send();
@@ -108,8 +113,16 @@ std::pair<std::string, std::string> split_ip_port_cport(const std::string &s) {
return std::make_pair(ret[0], ret[1]);
}
+void signal_handler(int) {
+ throw HotStuffError("got terminal signal");
+}
+
int main(int argc, char **argv) {
Config config("hotstuff.conf");
+
+ signal(SIGTERM, signal_handler);
+ signal(SIGINT, signal_handler);
+
auto opt_idx = Config::OptValInt::create(0);
auto opt_replicas = Config::OptValStrVec::create();
auto opt_max_iter_num = Config::OptValInt::create(100);
@@ -152,6 +165,13 @@ int main(int argc, char **argv) {
eb.dispatch();
} catch (HotStuffError &e) {
HOTSTUFF_LOG_ERROR("exception: %s", std::string(e).c_str());
+ for (const auto &e: elapsed)
+ {
+ char fmt[64];
+ struct tm *tmp = localtime(&e.first.tv_sec);
+ strftime(fmt, sizeof fmt, "%Y-%m-%d %H:%M:%S.%%06u [hotstuff info] %%.6f\n", tmp);
+ fprintf(stderr, fmt, e.first.tv_usec, e.second);
+ }
}
return 0;
}