From d959b9c8db4e9ba9695c08ae6c2f06edb6e82fdc Mon Sep 17 00:00:00 2001 From: Determinant Date: Sat, 8 Sep 2018 22:40:42 -0400 Subject: add non-zero payload to CommandDummy --- include/hotstuff/client.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/include/hotstuff/client.h b/include/hotstuff/client.h index 447a9db..d61d9e7 100644 --- a/include/hotstuff/client.h +++ b/include/hotstuff/client.h @@ -29,23 +29,36 @@ class CommandDummy: public Command { uint32_t cid; uint32_t n; uint256_t hash; +#if HOTSTUFF_CMD_DMSIZE > 0 + uint8_t payload[HOTSTUFF_CMD_DMSIZE]; +#endif + uint256_t compute_hash() { + DataStream s; + s << cid << n; + return s.get_hash(); + } public: - CommandDummy() {} - ~CommandDummy() override {} CommandDummy(uint32_t cid, uint32_t n): - cid(cid), n(n), hash(salticidae::get_hash(*this)) {} + cid(cid), n(n), hash(compute_hash()) {} void serialize(DataStream &s) const override { s << cid << n; +#if HOTSTUFF_CMD_DMSIZE > 0 + s.put_data(payload, payload + HOTSTUFF_CMD_DMSIZE); +#endif } void unserialize(DataStream &s) override { s >> cid >> n; - hash = salticidae::get_hash(*this); +#if HOTSTUFF_CMD_DMSIZE > 0 + auto base = s.get_data_inplace(HOTSTUFF_CMD_DMSIZE); + memmove(payload, base, HOTSTUFF_CMD_DMSIZE); +#endif + hash = compute_hash(); } const uint256_t &get_hash() const override { -- cgit v1.2.3