diff options
Diffstat (limited to 'include/hotstuff/client.h')
-rw-r--r-- | include/hotstuff/client.h | 21 |
1 files 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 { |