-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraft_protocol.cc
More file actions
60 lines (51 loc) · 1.72 KB
/
raft_protocol.cc
File metadata and controls
60 lines (51 loc) · 1.72 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "raft_protocol.h"
marshall &operator<<(marshall &m, const request_vote_args &args) {
// Lab3: Your code here
m << args.term_ << args.candidate_id_ << args.last_log_index_ << args.last_log_term_;
return m;
}
unmarshall &operator>>(unmarshall &u, request_vote_args &args) {
// Lab3: Your code here
u >> args.term_ >> args.candidate_id_ >> args.last_log_index_ >> args.last_log_term_;
return u;
}
marshall &operator<<(marshall &m, const request_vote_reply &reply) {
// Lab3: Your code here
m << reply.term_ << reply.vote_granted_;
return m;
}
unmarshall &operator>>(unmarshall &u, request_vote_reply &reply) {
// Lab3: Your code here
u >> reply.term_ >> reply.vote_granted_;
return u;
}
marshall &operator<<(marshall &m, const append_entries_reply &args) {
// Lab3: Your code here
m << args.term_ << args.success_ << args.match_index_;
return m;
}
unmarshall &operator>>(unmarshall &m, append_entries_reply &args) {
// Lab3: Your code here
m >> args.term_ >> args.success_ >> args.match_index_;
return m;
}
marshall &operator<<(marshall &m, const install_snapshot_args &args) {
// Lab3: Your code here
m << args.term_ << args.leader_id_ << args.last_included_index_ << args.last_included_term_ << args.data_;
return m;
}
unmarshall &operator>>(unmarshall &u, install_snapshot_args &args) {
// Lab3: Your code here
u >> args.term_ >> args.leader_id_ >> args.last_included_index_ >> args.last_included_term_ >> args.data_;
return u;
}
marshall &operator<<(marshall &m, const install_snapshot_reply &reply) {
// Lab3: Your code here
m << reply.term_;
return m;
}
unmarshall &operator>>(unmarshall &u, install_snapshot_reply &reply) {
// Lab3: Your code here
u >> reply.term_;
return u;
}