aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/hotstuff/liveness.h31
-rw-r--r--src/consensus.cpp10
-rw-r--r--src/hotstuff_app.cpp2
3 files changed, 27 insertions, 16 deletions
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));
}
diff --git a/src/consensus.cpp b/src/consensus.cpp
index 6505c20..58c0f31 100644
--- a/src/consensus.cpp
+++ b/src/consensus.cpp
@@ -173,7 +173,7 @@ 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);
+ if (bnew->qc_ref) on_qc_finish(bnew->qc_ref);
on_receive_proposal_(prop);
do_vote(prop.proposer,
Vote(id,
@@ -271,11 +271,15 @@ void HotStuffCore::on_qc_finish(const block_t &blk) {
}
promise_t HotStuffCore::async_wait_propose() {
- return propose_waiting;
+ return propose_waiting.then([](const block_t &blk) {
+ return blk;
+ });
}
promise_t HotStuffCore::async_wait_receive_proposal() {
- return receive_proposal_waiting;
+ return receive_proposal_waiting.then([](const Proposal &prop) {
+ return prop;
+ });
}
void HotStuffCore::on_propose_(const block_t &blk) {
diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp
index 2b6e0db..3b65649 100644
--- a/src/hotstuff_app.cpp
+++ b/src/hotstuff_app.cpp
@@ -173,7 +173,7 @@ int main(int argc, char **argv) {
auto parent_limit = opt_parent_limit->get();
hotstuff::pacemaker_bt pmaker;
if (opt_pace_maker->get() == "sticky")
- pmaker = new hotstuff::PaceMakerSticky(parent_limit, 1, ec);
+ pmaker = new hotstuff::PaceMakerSticky(parent_limit, 5, ec);
else
pmaker = new hotstuff::PaceMakerDummyFixed(1, parent_limit);