-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraft_protocol.cc
71 lines (62 loc) · 1.69 KB
/
raft_protocol.cc
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
61
62
63
64
65
66
67
68
69
70
71
#include "raft_protocol.h"
marshall& operator<<(marshall &m, const request_vote_args& args) {
// Your code here
m << args.term;
m << args.candidate_id;
m << args.last_log_index;
m << args.last_log_term;
return m;
}
unmarshall& operator>>(unmarshall &u, request_vote_args& args) {
// Your code here
u >> args.term;
u >> args.candidate_id;
u >> args.last_log_index;
u >> args.last_log_term;
return u;
}
marshall& operator<<(marshall &m, const request_vote_reply& reply) {
// Your code here
m << reply.term;
m << reply.vote_granted;
return m;
}
unmarshall& operator>>(unmarshall &u, request_vote_reply& reply) {
// Your code here
u >> reply.term;
u >> reply.vote_granted;
return u;
}
marshall& operator<<(marshall &m, const append_entries_reply& reply) {
// Your code here
m << reply.term << reply.success;
return m;
}
unmarshall& operator>>(unmarshall &m, append_entries_reply& reply) {
// Your code here
m >> reply.term;
m >> reply.success;
return m;
}
marshall& operator<<(marshall &m, const install_snapshot_args& args) {
// Your code here
m << args.term << args.last_include_index
<< args.last_include_term << args.data;
return m;
}
unmarshall& operator>>(unmarshall &u, install_snapshot_args& args) {
// Your code here
u >> args.term >> args.last_include_index
>> args.last_include_term >> args.data;
return u;
}
marshall& operator<<(marshall &m, const install_snapshot_reply& reply) {
// Your code here
m << reply.term;
return m;
}
unmarshall& operator>>(unmarshall &u, install_snapshot_reply& reply) {
// Your code here
u >> reply.term;
return u;
}