From 9e745354fe10f31b829f0c02a2aa464f391ffd19 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 18 Jul 2018 21:44:40 -0400 Subject: ... --- src/hotstuff.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/hotstuff.cpp') diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp index ed15cc1..6230d06 100644 --- a/src/hotstuff.cpp +++ b/src/hotstuff.cpp @@ -1,4 +1,5 @@ #include "hotstuff/hotstuff.h" +#include "hotstuff/client.h" using salticidae::static_pointer_cast; @@ -70,10 +71,14 @@ void MsgHotStuff::parse_rfetchblk(std::vector &blks, HotStuffCore *hsc) } } -ReplicaID HotStuffBase::add_command(command_t cmd) { +promise_t HotStuffBase::exec_command(command_t cmd) { ReplicaID proposer = pmaker->get_proposer(); + /* not the proposer */ if (proposer != get_id()) - return proposer; + return promise_t([proposer, cmd](promise_t &pm) { + pm.resolve(Finality(proposer, -1, + cmd->get_hash(), uint256_t())); + }); cmd_pending.push(storage->add_cmd(cmd)); if (cmd_pending.size() >= blk_size) { @@ -87,7 +92,13 @@ ReplicaID HotStuffBase::add_command(command_t cmd) { on_propose(cmds, pmaker->get_parents()); }); } - return proposer; + return async_decide(cmd->get_hash()).then([this](const command_t &cmd) { + block_t blk = cmd->get_container(); + return Finality(get_id(), + cmd->get_decision(), + cmd->get_hash(), + blk->get_hash()); + }); } void HotStuffBase::add_replica(ReplicaID idx, const NetAddr &addr, -- cgit v1.2.3