From 7e91de67703a3a3eb292d1a2422acb15a10d4b95 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 2 Jul 2019 01:17:15 -0400 Subject: update net lib --- src/hotstuff.cpp | 13 ++++++++----- src/hotstuff_client.cpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp index 5e75cc3..54b80e4 100644 --- a/src/hotstuff.cpp +++ b/src/hotstuff.cpp @@ -192,7 +192,8 @@ promise_t HotStuffBase::async_deliver_blk(const uint256_t &blk_hash, } void HotStuffBase::propose_handler(MsgPropose &&msg, const Net::conn_t &conn) { - const NetAddr &peer = conn->get_peer(); + const NetAddr &peer = conn->get_peer_addr(); + if (peer.is_null()) return; msg.postponed_parse(this); auto &prop = msg.proposal; block_t blk = prop.blk; @@ -205,7 +206,8 @@ void HotStuffBase::propose_handler(MsgPropose &&msg, const Net::conn_t &conn) { } void HotStuffBase::vote_handler(MsgVote &&msg, const Net::conn_t &conn) { - const NetAddr &peer = conn->get_peer(); + const NetAddr &peer = conn->get_peer_addr(); + if (peer.is_null()) return; msg.postponed_parse(this); //auto &vote = msg.vote; RcObj v(new Vote(std::move(msg.vote))); @@ -221,7 +223,8 @@ void HotStuffBase::vote_handler(MsgVote &&msg, const Net::conn_t &conn) { } void HotStuffBase::req_blk_handler(MsgReqBlock &&msg, const Net::conn_t &conn) { - const NetAddr replica = conn->get_peer(); + const NetAddr replica = conn->get_peer_addr(); + if (replica.is_null()) return; auto &blk_hashes = msg.blk_hashes; std::vector pms; for (const auto &h: blk_hashes) @@ -341,8 +344,8 @@ HotStuffBase::HotStuffBase(uint32_t blk_size, } void HotStuffBase::do_broadcast_proposal(const Proposal &prop) { - MsgPropose prop_msg(prop); - pn.multicast_msg(prop_msg, peers); + //MsgPropose prop_msg(prop); + pn.multicast_msg(MsgPropose(prop), peers); //for (const auto &replica: peers) // pn.send_msg(prop_msg, replica); } diff --git a/src/hotstuff_client.cpp b/src/hotstuff_client.cpp index 2c8b738..08f2a2e 100644 --- a/src/hotstuff_client.cpp +++ b/src/hotstuff_client.cpp @@ -68,7 +68,7 @@ Net mn(ec, Net::Config()); void connect_all() { for (size_t i = 0; i < replicas.size(); i++) - conns.insert(std::make_pair(i, mn.connect(replicas[i]))); + conns.insert(std::make_pair(i, mn.connect_sync(replicas[i]))); } bool try_send(bool check = true) { -- cgit v1.2.3-70-g09d2