aboutsummaryrefslogtreecommitdiff
path: root/include/hotstuff/client.h
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-09-10 22:04:35 -0400
committerDeterminant <[email protected]>2018-09-10 22:04:35 -0400
commitfcdf89a2c36d3dc985d47ce46235c42d74123c5e (patch)
treee35da09bc3107e4c4fa2918142628e4e65e6138c /include/hotstuff/client.h
parenta1e1b2eab5a1d0ab24182c4c2cb28899aacf43c6 (diff)
...
Diffstat (limited to 'include/hotstuff/client.h')
-rw-r--r--include/hotstuff/client.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/include/hotstuff/client.h b/include/hotstuff/client.h
index 4fde7b2..b357fde 100644
--- a/include/hotstuff/client.h
+++ b/include/hotstuff/client.h
@@ -26,10 +26,12 @@ struct MsgRespCmd {
MsgRespCmd(const Finality &fin) {
serialized << fin;
#if HOTSTUFF_CMD_RESPSIZE > 0
- serialized.put_data(payload, payload + HOTSTUFF_CMD_RESPSIZE);
+ serialized.put_data(payload, payload + sizeof(payload));
#endif
}
- MsgRespCmd(DataStream &&s) { s >> fin; }
+ MsgRespCmd(DataStream &&s) {
+ s >> fin;
+ }
};
class CommandDummy: public Command {
@@ -39,32 +41,28 @@ class CommandDummy: public Command {
#if HOTSTUFF_CMD_REQSIZE > 0
uint8_t payload[HOTSTUFF_CMD_REQSIZE];
#endif
- uint256_t compute_hash() {
- DataStream s;
- s << cid << n;
-#if HOTSTUFF_CMD_REQSIZE > 0
- s.put_data(payload, payload + HOTSTUFF_CMD_REQSIZE);
-#endif
- return s.get_hash();
- }
public:
CommandDummy() {}
~CommandDummy() override {}
CommandDummy(uint32_t cid, uint32_t n):
- cid(cid), n(n), hash(compute_hash()) {}
+ cid(cid), n(n), hash(salticidae::get_hash(*this)) {}
void serialize(DataStream &s) const override {
s << cid << n;
#if HOTSTUFF_CMD_REQSIZE > 0
- s.put_data(payload, payload + HOTSTUFF_CMD_REQSIZE);
+ s.put_data(payload, payload + sizeof(payload));
#endif
}
void unserialize(DataStream &s) override {
s >> cid >> n;
- hash = compute_hash();
+#if HOTSTUFF_CMD_REQSIZE > 0
+ auto base = s.get_data_inplace(HOTSTUFF_CMD_REQSIZE);
+ memmove(payload, base, sizeof(payload));
+#endif
+ hash = salticidae::get_hash(*this);
}
const uint256_t &get_hash() const override {