From e08bf4e6a40cf82822c50b1433a573d0d8800f80 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 17 Jul 2018 20:02:52 -0400 Subject: add PaceMakerDummyFixed --- include/hotstuff/client.h | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'include/hotstuff/client.h') 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 -- cgit v1.2.3