diff options
author | Determinant <[email protected]> | 2018-07-16 04:13:57 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-07-16 04:13:57 -0400 |
commit | efd49718dfbb6c1f329e72026770b07a67348168 (patch) | |
tree | 4f29a41480c6ad42ad0fcf2b861c7acc7368b937 /src/client.cpp |
init
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp new file mode 100644 index 0000000..f787003 --- /dev/null +++ b/src/client.cpp @@ -0,0 +1,43 @@ +#include "client.h" + +namespace hotstuff { + +uint64_t CommandDummy::cnt = 0; + +void MsgClient::gen_reqcmd(const Command &cmd) { + DataStream s; + set_opcode(REQ_CMD); + s << cmd; + set_payload(std::move(s)); +} + +void MsgClient::parse_reqcmd(CommandDummy &cmd) const { + DataStream s(get_payload()); + s >> cmd; +} + +void MsgClient::gen_respcmd(const uint256_t &cmd_hash, const Finality &fin) { + DataStream s; + set_opcode(RESP_CMD); + s << cmd_hash << fin; + set_payload(std::move(s)); +} + +void MsgClient::parse_respcmd(uint256_t &cmd_hash, Finality &fin) const { + DataStream s(get_payload()); + s >> cmd_hash >> fin; +} + +void MsgClient::gen_chkcmd(const uint256_t &cmd_hash) { + DataStream s; + set_opcode(CHK_CMD); + s << cmd_hash; + set_payload(std::move(s)); +} + +void MsgClient::parse_chkcmd(uint256_t &cmd_hash) const { + DataStream s(get_payload()); + s >> cmd_hash; +} + +} |