diff options
author | Determinant <tederminant@gmail.com> | 2018-07-17 20:02:52 -0400 |
---|---|---|
committer | Determinant <tederminant@gmail.com> | 2018-07-17 20:02:52 -0400 |
commit | e08bf4e6a40cf82822c50b1433a573d0d8800f80 (patch) | |
tree | 6b3ea8cabf94719f96dbacd176029a207a3920a6 /include/hotstuff/client.h | |
parent | 02e347dae1a01172dbcc2efe054014c015d96507 (diff) |
add PaceMakerDummyFixed
Diffstat (limited to 'include/hotstuff/client.h')
-rw-r--r-- | include/hotstuff/client.h | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/include/hotstuff/client.h b/include/hotstuff/client.h index 00ec77d..2127595 100644 --- a/include/hotstuff/client.h +++ b/include/hotstuff/client.h @@ -4,6 +4,7 @@ #include "salticidae/msg.h" #include "hotstuff/type.h" #include "hotstuff/entity.h" +#include "hotstuff/consensus.h" namespace hotstuff { @@ -13,6 +14,39 @@ enum { CHK_CMD = 0x6 }; +struct Finality: public Serializable { + ReplicaID rid; + int8_t decision; + uint256_t blk_hash; + + public: + Finality() = default; + Finality(ReplicaID rid, int8_t decision, uint256_t blk_hash): + rid(rid), decision(decision), blk_hash(blk_hash) {} + + void serialize(DataStream &s) const override { + s << rid << decision; + if (decision == 1) s << blk_hash; + } + + void unserialize(DataStream &s) override { + s >> rid >> decision; + if (decision == 1) s >> blk_hash; + } +}; + +struct MsgClient: public salticidae::MsgBase<> { + using MsgBase::MsgBase; + void gen_reqcmd(const Command &cmd); + void parse_reqcmd(command_t &cmd, HotStuffCore *hsc) const; + + void gen_respcmd(const uint256_t &cmd_hash, const Finality &fin); + void parse_respcmd(uint256_t &cmd_hash, Finality &fin) const; + + void gen_chkcmd(const uint256_t &cmd_hash); + void parse_chkcmd(uint256_t &cmd_hash) const; +}; + class CommandDummy: public Command { static uint64_t cnt; uint64_t n; @@ -49,18 +83,6 @@ class CommandDummy: public Command { } }; -struct MsgClient: public salticidae::MsgBase<> { - using MsgBase::MsgBase; - void gen_reqcmd(const Command &cmd); - void parse_reqcmd(CommandDummy &cmd) const; - - void gen_respcmd(const uint256_t &cmd_hash, const Finality &fin); - void parse_respcmd(uint256_t &cmd_hash, Finality &fin) const; - - void gen_chkcmd(const uint256_t &cmd_hash); - void parse_chkcmd(uint256_t &cmd_hash) const; -}; - } #endif |