From 062a1368abaa44585dcc4ea9b11e46708dbb418c Mon Sep 17 00:00:00 2001
From: Determinant <tederminant@gmail.com>
Date: Tue, 7 Aug 2018 17:27:57 -0400
Subject: sticky pace maker seems to work

---
 include/hotstuff/liveness.h | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

(limited to 'include')

diff --git a/include/hotstuff/liveness.h b/include/hotstuff/liveness.h
index 3d3137a..3d5a457 100644
--- a/include/hotstuff/liveness.h
+++ b/include/hotstuff/liveness.h
@@ -209,8 +209,8 @@ class PMStickyProposer: virtual public PaceMaker {
 
     void reg_follower_receive_proposal() {
         pm_wait_receive_proposal.reject();
-        pm_wait_receive_proposal =
-            hsc->async_wait_receive_proposal().then(
+        (pm_wait_receive_proposal = hsc->async_wait_receive_proposal())
+            .then(
                 salticidae::generic_bind(
                     &PMStickyProposer::follower_receive_proposal, this, _1));
     }
@@ -251,7 +251,7 @@ class PMStickyProposer: virtual public PaceMaker {
 
     void reg_proposer_propose() {
         pm_wait_propose.reject();
-        pm_wait_propose = hsc->async_wait_propose().then(
+        (pm_wait_propose = hsc->async_wait_propose()).then(
             salticidae::generic_bind(
                 &PMStickyProposer::proposer_propose, this, _1));
     }
@@ -263,27 +263,34 @@ class PMStickyProposer: virtual public PaceMaker {
         reg_proposer_propose();
     }
 
+    void gen() {
+        DataStream s;
+        /* FIXME: should extra data be the voter's id? */
+        s << hsc->get_id();
+        hsc->on_propose(std::vector<command_t>{},
+                get_parents(), std::move(s));
+    }
+
     void candidate_qc_timeout() {
         pm_qc_finish.reject();
-        hsc->async_wait_propose().then([this](const block_t &blk) {
+        pm_wait_propose.reject();
+        (pm_wait_propose = hsc->async_wait_propose()).then([this](const block_t &blk) {
             pm_qc_finish.reject();
-            pm_qc_finish = hsc->async_qc_finish(blk).then([this]() {
+            pm_qc_finish = hsc->async_qc_finish(blk).then([this, blk]() {
+                HOTSTUFF_LOG_INFO("collected QC for %s", std::string(*blk).c_str());
                 /* managed to collect a QC */
                 to_proposer();
+                gen();
             });
         });
         reset_qc_timer();
-        DataStream s;
-        /* FIXME: should extra data be the voter's id? */
-        s << hsc->get_id();
-        hsc->on_propose(std::vector<command_t>{},
-                        get_parents(), std::move(s));
+        gen();
     }
 
     void reg_candidate_receive_proposal() {
         pm_wait_receive_proposal.reject();
-        pm_wait_receive_proposal =
-            hsc->async_wait_receive_proposal().then(
+        (pm_wait_receive_proposal = hsc->async_wait_receive_proposal())
+            .then(
                 salticidae::generic_bind(
                     &PMStickyProposer::candidate_receive_proposal, this, _1));
     }
-- 
cgit v1.2.3-70-g09d2