From 88f2ebc8ab988d29c892661367e200e41a0c2723 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 11 Jan 2021 21:09:12 -0500 Subject: WIP: try always forwad vote to the next proposer --- src/consensus.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/consensus.cpp') diff --git a/src/consensus.cpp b/src/consensus.cpp index 9de7cc2..c6381a5 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -171,13 +171,10 @@ block_t HotStuffCore::on_propose(const std::vector &cmds, update(bnew); Proposal prop(id, bnew, nullptr); LOG_PROTO("propose %s", std::string(*bnew).c_str()); - /* self-vote */ if (bnew->height <= vheight) throw std::runtime_error("new block should be higher than vheight"); - vheight = bnew->height; - on_receive_vote( - Vote(id, bnew_hash, - create_part_cert(*priv_key, bnew_hash), this)); + /* self-receive the proposal (no need to send it through the network) */ + on_receive_proposal(prop); on_propose_(prop); /* boradcast to other replicas */ do_broadcast_proposal(prop); @@ -186,9 +183,13 @@ block_t HotStuffCore::on_propose(const std::vector &cmds, void HotStuffCore::on_receive_proposal(const Proposal &prop) { LOG_PROTO("got %s", std::string(prop).c_str()); + bool self_prop = prop.proposer == get_id(); block_t bnew = prop.blk; - sanity_check_delivered(bnew); - update(bnew); + if (!self_prop) + { + sanity_check_delivered(bnew); + update(bnew); + } bool opinion = false; if (bnew->height > vheight) { @@ -211,7 +212,7 @@ void HotStuffCore::on_receive_proposal(const Proposal &prop) { } } LOG_PROTO("now state: %s", std::string(*this).c_str()); - if (bnew->qc_ref) + if (!self_prop && bnew->qc_ref) on_qc_finish(bnew->qc_ref); on_receive_proposal_(prop); if (opinion && !vote_disabled) -- cgit v1.2.3