From c4d3e5fe66568ccd0732edf7cf80d37959d6abda Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 10 Sep 2018 20:49:34 -0400 Subject: let client send cmd data, the replicas should only work on the hash --- include/hotstuff/client.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'include/hotstuff/client.h') diff --git a/include/hotstuff/client.h b/include/hotstuff/client.h index d61d9e7..ca18062 100644 --- a/include/hotstuff/client.h +++ b/include/hotstuff/client.h @@ -12,25 +12,32 @@ struct MsgReqCmd { static const opcode_t opcode = 0x4; DataStream serialized; command_t cmd; - MsgReqCmd(const Command &cmd); + MsgReqCmd(const Command &cmd) { serialized << cmd; } MsgReqCmd(DataStream &&s): serialized(std::move(s)) {} - void postponed_parse(HotStuffCore *hsc); }; struct MsgRespCmd { static const opcode_t opcode = 0x5; DataStream serialized; +#if HOTSTUFF_CMD_RESPSIZE > 0 + uint8_t payload[HOTSTUFF_CMD_RESPSIZE]; +#endif Finality fin; - MsgRespCmd(const Finality &fin); - MsgRespCmd(DataStream &&s); + MsgRespCmd(const Finality &fin) { + serialized << fin; +#if HOTSTUFF_CMD_RESPSIZE > 0 + serialized.put_data(payload, payload + HOTSTUFF_CMD_RESPSIZE); +#endif + } + MsgRespCmd(DataStream &&s) { s >> fin; } }; class CommandDummy: public Command { uint32_t cid; uint32_t n; uint256_t hash; -#if HOTSTUFF_CMD_DMSIZE > 0 - uint8_t payload[HOTSTUFF_CMD_DMSIZE]; +#if HOTSTUFF_CMD_REQSIZE > 0 + uint8_t payload[HOTSTUFF_CMD_REQSIZE]; #endif uint256_t compute_hash() { DataStream s; @@ -47,17 +54,13 @@ class CommandDummy: public Command { void serialize(DataStream &s) const override { s << cid << n; -#if HOTSTUFF_CMD_DMSIZE > 0 - s.put_data(payload, payload + HOTSTUFF_CMD_DMSIZE); +#if HOTSTUFF_CMD_REQSIZE > 0 + s.put_data(payload, payload + HOTSTUFF_CMD_REQSIZE); #endif } void unserialize(DataStream &s) override { s >> cid >> n; -#if HOTSTUFF_CMD_DMSIZE > 0 - auto base = s.get_data_inplace(HOTSTUFF_CMD_DMSIZE); - memmove(payload, base, HOTSTUFF_CMD_DMSIZE); -#endif hash = compute_hash(); } -- cgit v1.2.3