diff options
author | Determinant <[email protected]> | 2018-09-08 22:40:42 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-09-08 22:40:42 -0400 |
commit | d959b9c8db4e9ba9695c08ae6c2f06edb6e82fdc (patch) | |
tree | 078974abcf7d5db65acfffd625cd7e47c89c7443 /include | |
parent | 4d30bae0a66778ce4dd05bd8b3706419f401a9b4 (diff) |
add non-zero payload to CommandDummy
Diffstat (limited to 'include')
-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 { |