diff options
author | Determinant <[email protected]> | 2019-07-06 18:37:11 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-07-06 18:37:11 -0400 |
commit | 24b6cea7be8b78eaa3681d6274d671057ed112b5 (patch) | |
tree | f3e8ae2a279344340085b96aa5622452dd5af624 /src/hotstuff.cpp | |
parent | 346f688916d87ff856a81e9cf3f3e69245101475 (diff) |
finish the simple Round-Robin Pacemakerpacemaker-clean-up
Diffstat (limited to 'src/hotstuff.cpp')
-rw-r--r-- | src/hotstuff.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp index 22f0d82..69501c0 100644 --- a/src/hotstuff.cpp +++ b/src/hotstuff.cpp @@ -17,6 +17,7 @@ #include "hotstuff/hotstuff.h" #include "hotstuff/client.h" +#include "hotstuff/liveness.h" using salticidae::static_pointer_cast; @@ -79,6 +80,17 @@ void HotStuffBase::exec_command(uint256_t cmd_hash, commit_cb_t callback) { cmd_pending.enqueue(std::make_pair(cmd_hash, callback)); } +void HotStuffBase::do_elected() { + // TODO: improve this + tcall.async_call([this](salticidae::ThreadCall::Handle &) { + HOTSTUFF_LOG_PROTO("reproposing waiting commands"); + std::vector<uint256_t> cmds; + for (auto &p: decision_waiting) + cmds.push_back(p.first); + on_propose(cmds, pmaker->get_parents()); + }); +} + void HotStuffBase::on_fetch_blk(const block_t &blk) { #ifdef HOTSTUFF_BLK_PROFILE blk_profiler.get_tx(blk->get_hash()); @@ -329,6 +341,7 @@ HotStuffBase::HotStuffBase(uint32_t blk_size, listen_addr(listen_addr), blk_size(blk_size), ec(ec), + tcall(ec), vpool(ec, nworker), pn(ec, netconfig), pmaker(std::move(pmaker)), @@ -420,21 +433,15 @@ void HotStuffBase::start( while (q.try_dequeue(e)) { ReplicaID proposer = pmaker->get_proposer(); - if (proposer != get_id()) continue; const auto &cmd_hash = e.first; - cmd_pending_buffer.push(cmd_hash); - auto it = decision_waiting.find(cmd_hash); if (it == decision_waiting.end()) - { it = decision_waiting.insert(std::make_pair(cmd_hash, e.second)).first; - } else - { - // TODO: duplicate commands - } - + e.second(Finality(id, 0, 0, 0, cmd_hash, uint256_t())); + if (proposer != get_id()) continue; + cmd_pending_buffer.push(cmd_hash); if (cmd_pending_buffer.size() >= blk_size) { std::vector<uint256_t> cmds; |