aboutsummaryrefslogtreecommitdiff
path: root/src/client.cpp
blob: 486594aaff554527736d6a30fcb10c27938ed50c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "hotstuff/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(command_t &cmd, HotStuffCore *hsc) const {
    DataStream s(get_payload());
    cmd = hsc->parse_cmd(s);
}

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;
}

}