From 4c42ac64c2ff821306609898a58126f2da32c7d4 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 2 Aug 2018 20:26:21 -0400 Subject: WIP: sticky proposer pacemaker --- src/consensus.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/consensus.cpp b/src/consensus.cpp index cc1d572..40a5e44 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -64,6 +64,7 @@ bool HotStuffCore::on_deliver_blk(const block_t &blk) { blk->delivered = true; LOG_DEBUG("deliver %s", std::string(*blk).c_str()); + on_deliver_blk_(blk); return true; } @@ -173,6 +174,8 @@ void HotStuffCore::on_receive_proposal(const Proposal &prop) { #ifdef HOTSTUFF_PROTO_LOG LOG_INFO("now state: %s", std::string(*this).c_str()); #endif + if (bnew->qc_ref) on_qc_finish(bnew); + on_receive_proposal_(prop); do_vote(prop.proposer, Vote(id, bqc->get_hash(), @@ -272,12 +275,22 @@ promise_t HotStuffCore::async_wait_propose() { return propose_waiting; } +promise_t HotStuffCore::async_wait_receive_proposal() { + return receive_proposal_waiting; +} + void HotStuffCore::on_propose_(const block_t &blk) { auto t = std::move(propose_waiting); propose_waiting = promise_t(); t.resolve(blk); } +void HotStuffCore::on_receive_proposal_(const Proposal &prop) { + auto t = std::move(receive_proposal_waiting); + receive_proposal_waiting = promise_t(); + t.resolve(prop); +} + HotStuffCore::operator std::string () const { DataStream s; s << "