-
Notifications
You must be signed in to change notification settings - Fork 0
/
raft_protocol.cc
50 lines (41 loc) · 1.43 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
#include "raft_protocol.h"
marshall& operator<<(marshall &m, const request_vote_args& args) {
m << args.term << args.candidateId << args.lastLogIndex << args.lastLogTerm;
return m;
}
unmarshall& operator>>(unmarshall &u, request_vote_args& args) {
u >> args.term >> args.candidateId >> args.lastLogIndex >> args.lastLogTerm;
return u;
}
marshall& operator<<(marshall &m, const request_vote_reply& reply) {
m << reply.term << reply.voteGranted;
return m;
}
unmarshall& operator>>(unmarshall &u, request_vote_reply& reply) {
u >> reply.term >> reply.voteGranted;
return u;
}
marshall& operator<<(marshall &m, const append_entries_reply& reply) {
m << reply.term << reply.success;
return m;
}
unmarshall& operator>>(unmarshall &u, append_entries_reply& reply) {
u >> reply.term >> reply.success;
return u;
}
marshall& operator<<(marshall &m, const install_snapshot_args& args) {
m << args.term << args.leaderId << args.lastIncludedIndex << args.lastIncludedTerm << args.snapshot;
return m;
}
unmarshall& operator>>(unmarshall &u, install_snapshot_args& args) {
u >> args.term >> args.leaderId >> args.lastIncludedIndex >> args.lastIncludedTerm >> args.snapshot;
return u;
}
marshall& operator<<(marshall &m, const install_snapshot_reply& reply) {
m << reply.term;
return m;
}
unmarshall& operator>>(unmarshall &u, install_snapshot_reply& reply) {
u >> reply.term;
return u;
}