From 6131c5e5cc1e83fdbfbc8fc4ce419765ba3d180a Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 31 Jul 2018 13:24:14 -0400 Subject: add cmake options --- src/config.h.in | 7 +++++-- src/consensus.cpp | 10 +++++----- src/hotstuff.cpp | 4 ++-- src/hotstuff_app.cpp | 31 ++++++------------------------- 4 files changed, 18 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/config.h.in b/src/config.h.in index ce1e575..eb92a20 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,7 +1,10 @@ #ifndef _HOTSTUFF_CONFIG_H #define _HOTSTUFF_CONFIG_H -#cmakedefine HOTSTUFF_ENABLE_DEBUG_LOG -#cmakedefine HOTSTUFF_ENABLE_NORMAL_LOG +#cmakedefine HOTSTUFF_DEBUG_LOG +#cmakedefine HOTSTUFF_NORMAL_LOG +#cmakedefine HOTSTUFF_PROTO_LOG +#cmakedefine HOTSTUFF_MSG_STAT +#cmakedefine HOTSTUFF_BLK_PROFILE #endif diff --git a/src/consensus.cpp b/src/consensus.cpp index ac7e56a..cc1d572 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -88,7 +88,7 @@ void HotStuffCore::check_commit(const block_t &_blk) { { const block_t &blk = *it; blk->decision = 1; -#ifdef HOTSTUFF_ENABLE_LOG_PROTO +#ifdef HOTSTUFF_PROTO_LOG LOG_INFO("commit %s", std::string(*blk).c_str()); #endif size_t idx = 0; @@ -137,7 +137,7 @@ void HotStuffCore::on_propose(const std::vector &cmds, on_deliver_blk(bnew); update(bnew_hash); Proposal prop(id, bqc->get_hash(), bnew, nullptr); -#ifdef HOTSTUFF_ENABLE_LOG_PROTO +#ifdef HOTSTUFF_PROTO_LOG LOG_INFO("propose %s", std::string(*bnew).c_str()); #endif /* self-vote */ @@ -151,7 +151,7 @@ void HotStuffCore::on_propose(const std::vector &cmds, void HotStuffCore::on_receive_proposal(const Proposal &prop) { if (!update(prop.bqc_hash)) return; -#ifdef HOTSTUFF_ENABLE_LOG_PROTO +#ifdef HOTSTUFF_PROTO_LOG LOG_INFO("got %s", std::string(prop).c_str()); #endif block_t bnew = prop.blk; @@ -170,7 +170,7 @@ void HotStuffCore::on_receive_proposal(const Proposal &prop) { vheight = bnew->height; } } -#ifdef HOTSTUFF_ENABLE_LOG_PROTO +#ifdef HOTSTUFF_PROTO_LOG LOG_INFO("now state: %s", std::string(*this).c_str()); #endif do_vote(prop.proposer, @@ -185,7 +185,7 @@ void HotStuffCore::on_receive_proposal(const Proposal &prop) { void HotStuffCore::on_receive_vote(const Vote &vote) { if (!update(vote.bqc_hash)) return; -#ifdef HOTSTUFF_ENABLE_LOG_PROTO +#ifdef HOTSTUFF_PROTO_LOG LOG_INFO("got %s", std::string(vote).c_str()); LOG_INFO("now state: %s", std::string(*this).c_str()); #endif diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp index c01f2f3..abd5116 100644 --- a/src/hotstuff.cpp +++ b/src/hotstuff.cpp @@ -96,7 +96,7 @@ void HotStuffBase::add_replica(ReplicaID idx, const NetAddr &addr, } void HotStuffBase::on_fetch_blk(const block_t &blk) { -#ifdef HOTSTUFF_ENABLE_TX_PROFILE +#ifdef HOTSTUFF_BLK_PROFILE blk_profiler.get_tx(blk->get_hash()); #endif LOG_DEBUG("fetched %.10s", get_hex(blk->get_hash()).c_str()); @@ -174,7 +174,7 @@ promise_t HotStuffBase::async_fetch_blk(const uint256_t &blk_hash, auto it = blk_fetch_waiting.find(blk_hash); if (it == blk_fetch_waiting.end()) { -#ifdef HOTSTUFF_ENABLE_TX_PROFILE +#ifdef HOTSTUFF_BLK_PROFILE blk_profiler.rec_tx(blk_hash, false); #endif it = blk_fetch_waiting.insert( diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp index e91919e..8edec56 100644 --- a/src/hotstuff_app.cpp +++ b/src/hotstuff_app.cpp @@ -134,7 +134,7 @@ int main(int argc, char **argv) { config.add_opt("help", opt_help, Config::SWITCH_ON, 'h', "show this help info"); EventContext eb; -#ifndef HOTSTUFF_ENABLE_LOG_DEBUG +#ifdef HOTSTUFF_NORMAL_LOG try { #endif config.parse(argc, argv); @@ -185,7 +185,7 @@ int main(int argc, char **argv) { hotstuff::from_hex(replicas[i].second)); } papp->start(); -#ifndef HOTSTUFF_ENABLE_LOG_DEBUG +#ifdef HOTSTUFF_NORMAL_LOG } catch (std::exception &e) { HOTSTUFF_LOG_INFO("exception: %s", e.what()); elapsed.stop(true); @@ -220,24 +220,10 @@ void HotStuffApp::client_request_cmd_handler(MsgReqCmd &&msg, conn_t conn) { msg.postponed_parse(this); auto cmd = msg.cmd; std::vector pms; - bool flag = true; -#ifndef HOTSTUFF_DISABLE_TX_VERIFY - flag &= cmd->verify(); -#endif - const uint256_t cmd_hash = cmd->get_hash(); - if (!flag) - { - LOG_WARN("invalid client cmd"); - cn.send_msg(MsgRespCmd( - Finality(get_id(), -1, 0, 0, cmd_hash, uint256_t())), addr); - } - else - { - LOG_DEBUG("processing %s", std::string(*cmd).c_str()); - exec_command(cmd).then([this, addr](Finality fin) { - cn.send_msg(MsgRespCmd(fin), addr); - }); - } + LOG_DEBUG("processing %s", std::string(*cmd).c_str()); + exec_command(cmd).then([this, addr](Finality fin) { + cn.send_msg(MsgRespCmd(fin), addr); + }); } void HotStuffApp::start() { @@ -249,11 +235,6 @@ void HotStuffApp::start() { LOG_INFO("parent_limit = %d", parent_limit); LOG_INFO("conns = %lu", HotStuff::size()); LOG_INFO("** starting the event loop..."); -#ifdef HOTSTUFF_DISABLE_TX_VERIFY - LOG_INFO("!! verification disabled !!"); -#else - LOG_INFO("** verification enabled **"); -#endif HotStuff::start(); /* enter the event main loop */ eb.dispatch(); -- cgit v1.2.3