From 56a5a5570055208b5b791d0e11a49cf43a4a332e Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 1 Aug 2018 13:31:02 -0400 Subject: ... --- include/hotstuff/hotstuff.h | 10 +++++----- salticidae | 2 +- src/hotstuff.cpp | 14 +++++++------- src/hotstuff_app.cpp | 8 ++++---- src/hotstuff_client.cpp | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/hotstuff/hotstuff.h b/include/hotstuff/hotstuff.h index 287cbac..41c83b4 100644 --- a/include/hotstuff/hotstuff.h +++ b/include/hotstuff/hotstuff.h @@ -116,7 +116,7 @@ class BlockDeliveryContext: public promise_t { class HotStuffBase: public HotStuffCore { using BlockFetchContext = FetchContext; using CmdFetchContext = FetchContext; - using conn_t = PeerNetwork::conn_t; + using Conn = PeerNetwork::Conn; friend BlockFetchContext; friend CmdFetchContext; @@ -166,13 +166,13 @@ class HotStuffBase: public HotStuffCore { void on_deliver_blk(const block_t &blk); /** deliver consensus message: */ - inline void propose_handler(MsgPropose &&, conn_t); + inline void propose_handler(MsgPropose &&, Conn &); /** deliver consensus message: */ - inline void vote_handler(MsgVote &&, conn_t); + inline void vote_handler(MsgVote &&, Conn &); /** fetches full block data */ - inline void req_blk_handler(MsgReqBlock &&, conn_t); + inline void req_blk_handler(MsgReqBlock &&, Conn &); /** receives a block */ - inline void resp_blk_handler(MsgRespBlock &&, conn_t); + inline void resp_blk_handler(MsgRespBlock &&, Conn &); void do_broadcast_proposal(const Proposal &) override; void do_vote(ReplicaID, const Vote &) override; diff --git a/salticidae b/salticidae index c9faab3..bc078ab 160000 --- a/salticidae +++ b/salticidae @@ -1 +1 @@ -Subproject commit c9faab354fb314bacd9849503d8b4566a8c9ea62 +Subproject commit bc078abd9d5fcc420dfbcda06869a95aba39b1ea diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp index abd5116..9a56626 100644 --- a/src/hotstuff.cpp +++ b/src/hotstuff.cpp @@ -233,8 +233,8 @@ promise_t HotStuffBase::async_deliver_blk(const uint256_t &blk_hash, return static_cast(pm); } -void HotStuffBase::propose_handler(MsgPropose &&msg, conn_t conn) { - const NetAddr &peer = conn->get_peer(); +void HotStuffBase::propose_handler(MsgPropose &&msg, Conn &conn) { + const NetAddr &peer = conn.get_peer(); msg.postponed_parse(this); auto &prop = msg.proposal; block_t blk = prop.blk; @@ -247,8 +247,8 @@ void HotStuffBase::propose_handler(MsgPropose &&msg, conn_t conn) { }); } -void HotStuffBase::vote_handler(MsgVote &&msg, conn_t conn) { - const NetAddr &peer = conn->get_peer(); +void HotStuffBase::vote_handler(MsgVote &&msg, Conn &conn) { + const NetAddr &peer = conn.get_peer(); msg.postponed_parse(this); auto &vote = msg.vote; promise::all(std::vector{ @@ -259,8 +259,8 @@ void HotStuffBase::vote_handler(MsgVote &&msg, conn_t conn) { }); } -void HotStuffBase::req_blk_handler(MsgReqBlock &&msg, conn_t conn) { - const NetAddr replica = conn->get_peer(); +void HotStuffBase::req_blk_handler(MsgReqBlock &&msg, Conn &conn) { + const NetAddr replica = conn.get_peer(); auto &blk_hashes = msg.blk_hashes; std::vector pms; for (const auto &h: blk_hashes) @@ -276,7 +276,7 @@ void HotStuffBase::req_blk_handler(MsgReqBlock &&msg, conn_t conn) { }); } -void HotStuffBase::resp_blk_handler(MsgRespBlock &&msg, conn_t) { +void HotStuffBase::resp_blk_handler(MsgRespBlock &&msg, Conn &) { msg.postponed_parse(this); for (const auto &blk: msg.blks) if (blk) on_fetch_blk(blk); diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp index 8edec56..9a6e5fd 100644 --- a/src/hotstuff_app.cpp +++ b/src/hotstuff_app.cpp @@ -65,9 +65,9 @@ class HotStuffApp: public HotStuff { /** Maximum number of parents. */ int32_t parent_limit; - using conn_t = ClientNetwork::conn_t; + using Conn = ClientNetwork::Conn; - void client_request_cmd_handler(MsgReqCmd &&, conn_t); + void client_request_cmd_handler(MsgReqCmd &&, Conn &); void print_stat_cb(evutil_socket_t, short); command_t parse_cmd(DataStream &s) override { @@ -215,8 +215,8 @@ HotStuffApp::HotStuffApp(uint32_t blk_size, cn.listen(clisten_addr); } -void HotStuffApp::client_request_cmd_handler(MsgReqCmd &&msg, conn_t conn) { - const NetAddr addr = conn->get_addr(); +void HotStuffApp::client_request_cmd_handler(MsgReqCmd &&msg, Conn &conn) { + const NetAddr addr = conn.get_addr(); msg.postponed_parse(this); auto cmd = msg.cmd; std::vector pms; diff --git a/src/hotstuff_client.cpp b/src/hotstuff_client.cpp index e213e78..bee8abd 100644 --- a/src/hotstuff_client.cpp +++ b/src/hotstuff_client.cpp @@ -55,7 +55,7 @@ void try_send() { while (waiting.size() < max_async_num && max_iter_num) { auto cmd = CommandDummy::make_cmd(); - mn.send_msg(MsgReqCmd(*cmd), conns.find(proposer)->second); + mn.send_msg(MsgReqCmd(*cmd), *conns.at(proposer)); HOTSTUFF_LOG_INFO("send new cmd %.10s", get_hex(cmd->get_hash()).c_str()); waiting.insert(std::make_pair( @@ -65,7 +65,7 @@ void try_send() { } } -void client_resp_cmd_handler(MsgRespCmd &&msg, MsgNetwork::conn_t) { +void client_resp_cmd_handler(MsgRespCmd &&msg, MsgNetwork::Conn &) { auto &fin = msg.fin; HOTSTUFF_LOG_DEBUG("got %s", std::string(msg.fin).c_str()); const uint256_t &cmd_hash = fin.cmd_hash; @@ -78,7 +78,7 @@ void client_resp_cmd_handler(MsgRespCmd &&msg, MsgNetwork::conn_t) { if (fin.rid != it->second.rid) { mn.send_msg(MsgReqCmd(*(waiting.find(cmd_hash)->second.cmd)), - conns.find(proposer)->second); + *conns.at(proposer)); HOTSTUFF_LOG_INFO("resend cmd %.10s", get_hex(cmd_hash).c_str()); it->second.et.start(); -- cgit v1.2.3-70-g09d2