From 4360a816bd31a2520c3a2cefcd780e157ec3e4cb Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 8 Apr 2019 10:53:02 -0400 Subject: fix minor bug --- src/consensus.cpp | 7 +++---- src/hotstuff.cpp | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/consensus.cpp b/src/consensus.cpp index b57e258..d801de8 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -119,10 +119,9 @@ void HotStuffCore::update(const block_t &nblk) { const block_t &blk = *it; blk->decision = 1; LOG_PROTO("commit %s", std::string(*blk).c_str()); - size_t idx = 0; - for (auto cmd: blk->cmds) - do_decide(Finality(id, 1, idx, blk->height, - cmd, blk->get_hash())); + for (size_t i = 0; i < blk->cmds.size(); i++) + do_decide(Finality(id, 1, i, blk->height, + blk->cmds[i], blk->get_hash())); } bexec = p; } diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp index 9b36fa2..aeae2e2 100644 --- a/src/hotstuff.cpp +++ b/src/hotstuff.cpp @@ -85,10 +85,11 @@ promise_t HotStuffBase::exec_command(uint256_t cmd_hash) { }); auto it = decision_waiting.find(cmd_hash); + promise_t pm{}; if (it == decision_waiting.end()) { cmd_pending.push(cmd_hash); - it = decision_waiting.insert(std::make_pair(cmd_hash, promise_t())).first; + it = decision_waiting.insert(std::make_pair(cmd_hash, pm)).first; } if (cmd_pending.size() >= blk_size) @@ -117,7 +118,7 @@ promise_t HotStuffBase::exec_command(uint256_t cmd_hash) { on_propose(cmds, pmaker->get_parents()); }); } - return it->second; + return pm; } void HotStuffBase::on_fetch_blk(const block_t &blk) { -- cgit v1.2.3