-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraft_protocol.cc
92 lines (73 loc) · 1.85 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "raft_protocol.h"
marshall& operator<<(marshall &m, const request_vote_args& args) {
// Your code here
m << args.term;
m << args.candidateId;
m << args.lastLogIndex;
m << args.lastLogTerm;
return m;
}
unmarshall& operator>>(unmarshall &u, request_vote_args& args) {
// Your code here
u >> args.term;
u >> args.candidateId;
u >> args.lastLogIndex;
u >> args.lastLogTerm;
return u;
}
marshall& operator<<(marshall &m, const request_vote_reply& reply) {
// Your code here
m << reply.term;
m << reply.voteGranted;
return m;
}
unmarshall& operator>>(unmarshall &u, request_vote_reply& reply) {
// Your code here
u >> reply.term;
u >> reply.voteGranted;
return u;
}
marshall& operator<<(marshall &m, const append_entries_reply& reply) {
// Your code here
m << reply.term;
m << reply.success;
return m;
}
unmarshall& operator>>(unmarshall &u, append_entries_reply& reply) {
// Your code here
u >> reply.term;
u >> reply.success;
return u;
}
marshall& operator<<(marshall &m, const install_snapshot_args& args) {
// Your code here
m << args.term;
m << args.leaderId;
m << args.lastIncludedIndex;
m << args.lastIncludedTerm;
m << args.offset;
m << args.data;
m << args.done;
return m;
}
unmarshall& operator>>(unmarshall &u, install_snapshot_args& args) {
// Your code here
u >> args.term;
u >> args.leaderId;
u >> args.lastIncludedIndex;
u >> args.lastIncludedTerm;
u >> args.offset;
u >> args.data;
u >> args.done;
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;
}