diff options
author | Determinant <[email protected]> | 2018-07-20 20:09:24 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-07-20 20:09:24 -0400 |
commit | 41efd33a3e165ac329f14b6e1cea935076a8b790 (patch) | |
tree | 129dc7a6e161edffa35917707df7273a97cf1dfd /src/client.cpp | |
parent | 928b2c1910bfe957a4cc31746aa395c9ed98006f (diff) |
improve msg & msg network interface
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/src/client.cpp b/src/client.cpp index bc790bc..562fab5 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -4,40 +4,14 @@ 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)); +const opcode_t MsgReqCmd::opcode; +MsgReqCmd::MsgReqCmd(const Command &cmd) { serialized << cmd; } +void MsgReqCmd::postponed_parse(HotStuffCore *hsc) { + cmd = hsc->parse_cmd(serialized); } -void MsgClient::parse_reqcmd(command_t &cmd, HotStuffCore *hsc) const { - DataStream s(get_payload()); - cmd = hsc->parse_cmd(s); -} - -void MsgClient::gen_respcmd(const Finality &fin) { - DataStream s; - set_opcode(RESP_CMD); - s << fin; - set_payload(std::move(s)); -} - -void MsgClient::parse_respcmd(Finality &fin) const { - DataStream s(get_payload()); - s >> 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; -} +const opcode_t MsgRespCmd::opcode; +MsgRespCmd::MsgRespCmd(const Finality &fin) { serialized << fin; } +MsgRespCmd::MsgRespCmd(DataStream &&s) { s >> fin; } } |