-
Notifications
You must be signed in to change notification settings - Fork 1
/
paxmsg.cpp
executable file
·62 lines (54 loc) · 2.43 KB
/
paxmsg.cpp
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
// Basic routines for Paxos implementation
#include "make_unique.h"
#include "dssim.h"
#include "paxmsg.h"
////////////////////////////////////////////////////
// Basic operations
bool operator <(const viewid_t& x, const viewid_t& y) {
return std::tie(x.counter, x.manager) < std::tie(y.counter, y.manager);
}
bool operator <=(const viewid_t& x, const viewid_t& y) {
return std::tie(x.counter, x.manager) <= std::tie(y.counter, y.manager);
}
bool operator >(const viewid_t& x, const viewid_t& y) {
return std::tie(x.counter, x.manager) > std::tie(y.counter, y.manager);
}
bool operator >=(const viewid_t& x, const viewid_t& y) {
return std::tie(x.counter, x.manager) >= std::tie(y.counter, y.manager);
}
bool operator <(const viewstamp_t& x, const viewstamp_t& y) {
return std::tie(x.vid, x.ts) < std::tie(y.vid, y.ts);
}
bool operator <=(const viewstamp_t& x, const viewstamp_t& y) {
return std::tie(x.vid, x.ts) <= std::tie(y.vid, y.ts);
}
bool operator >(const viewstamp_t& x, const viewstamp_t& y) {
return std::tie(x.vid, x.ts) > std::tie(y.vid, y.ts);
}
bool operator >=(const viewstamp_t& x, const viewstamp_t& y) {
return std::tie(x.vid, x.ts) >= std::tie(y.vid, y.ts);
}
std::unordered_map<int, std::string> paxrpc2str = {
{execute_arg::ID, execute_arg::_descr},
{replicate_arg::ID, replicate_arg::_descr},
{replicate_res::ID, replicate_res::_descr},
{accept_arg::ID, accept_arg::_descr},
{execute_success::ID, execute_success::_descr},
{execute_fail::ID, execute_fail::_descr},
{view_change_arg::ID, view_change_arg::_descr},
{view_change_reject::ID,view_change_reject::_descr},
{view_change_accept::ID,view_change_accept::_descr},
{new_view_arg::ID, new_view_arg::_descr},
{new_view_res::ID, new_view_res::_descr},
{init_view_arg::ID, init_view_arg::_descr},
{init_view_request::ID, init_view_request::_descr},
{getstate_arg::ID, getstate_arg::_descr},
{getstate_res::ID, getstate_res::_descr},
{prepare_batch_msg_t::ID, prepare_batch_msg_t::_descr},
{promise_batch_msg_t::ID, promise_batch_msg_t::_descr},
{accept_msg_t::ID, accept_msg_t::_descr},
{learner_sync_msg_t::ID, learner_sync_msg_t::_descr},
{learn_msg_t::ID, learn_msg_t::_descr},
{anyval_batch_msg_t::ID, anyval_batch_msg_t::_descr},
{nop_msg::ID, nop_msg::_descr},
};