Working on g++ compatibility
[invirt/third/libt4.git] / paxos_protocol.h
1 #ifndef paxos_protocol_h
2 #define paxos_protocol_h
3
4 #include "types.h"
5 #include "rpc/rpc.h"
6
7 struct prop_t {
8     unsigned n;
9     string m;
10
11     MEMBERS(n, m)
12     LEXICOGRAPHIC_COMPARISON(prop_t)
13 };
14
15 MARSHALLABLE_STRUCT(prop_t)
16
17 namespace paxos_protocol {
18     enum status : rpc_protocol::status { OK, ERR };
19     struct prepareres {
20         bool oldinstance;
21         bool accept;
22         prop_t n_a;
23         string v_a;
24
25         MEMBERS(oldinstance, accept, n_a, v_a)
26     };
27     using node_t = string;
28     using nodes_t = vector<node_t>;
29     using value_t = string;
30
31     REMOTE_PROCEDURE_BASE(0x11000);
32     REMOTE_PROCEDURE(1, preparereq, (prepareres &, node_t, unsigned, prop_t));
33     REMOTE_PROCEDURE(2, acceptreq, (bool &, node_t, unsigned, prop_t, value_t));
34     REMOTE_PROCEDURE(3, decidereq, (int &, node_t, unsigned, value_t));
35     REMOTE_PROCEDURE(4, heartbeat, (int &, string, unsigned));
36 };
37
38 MARSHALLABLE_STRUCT(paxos_protocol::prepareres)
39
40 #endif