6
6
typedef struct raft_data_t * raft_t ;
7
7
typedef struct raft_msg_data_t * raft_msg_t ;
8
8
9
+ typedef int raft_bool_t ;
10
+
9
11
typedef struct raft_update_t {
10
12
int len ;
11
13
char * data ;
@@ -17,7 +19,7 @@ typedef struct raft_update_t {
17
19
// This should be a function that applies an 'update' to the state machine.
18
20
// 'snapshot' is true if 'update' contains a snapshot. 'userdata' is the
19
21
// userdata that raft was configured with.
20
- typedef void (* raft_applier_t )(void * userdata ,raft_update_t update ,bool snapshot );
22
+ typedef void (* raft_applier_t )(void * userdata ,raft_update_t update ,raft_bool_t snapshot );
21
23
22
24
// This should be a function that makes a snapshot of the state machine. Used
23
25
// for raft log compaction. 'userdata' is the userdata that raft was configured
@@ -48,10 +50,10 @@ raft_t raft_init(raft_config_t *config);
48
50
49
51
// Add a peer named 'id'. 'self' should be true, if that peer is this instance.
50
52
// Only one peer should have 'self' == true.
51
- bool raft_peer_up (raft_t r ,int id ,char * host ,int port ,bool self );
53
+ raft_bool_t raft_peer_up (raft_t r ,int id ,char * host ,int port ,raft_bool_t self );
52
54
53
55
// Remove a previously added peer named 'id'.
54
- bool raft_peer_down (raft_t r ,int id );
56
+ raft_bool_t raft_peer_down (raft_t r ,int id );
55
57
56
58
// --- Log Actions ---
57
59
@@ -60,7 +62,7 @@ bool raft_peer_down(raft_t r, int id);
60
62
int raft_emit (raft_t r ,raft_update_t update );
61
63
62
64
// Checks whether an entry at 'index' has been applied by the peer named 'id'.
63
- bool raft_applied (raft_t t ,int id ,int index );
65
+ raft_bool_t raft_applied (raft_t t ,int id ,int index );
64
66
65
67
// --- Control ---
66
68
@@ -85,7 +87,7 @@ void raft_handle_message(raft_t r, raft_msg_t m);
85
87
int raft_create_udp_socket (raft_t r );
86
88
87
89
// Returns true if this peer thinks it is the leader.
88
- bool raft_is_leader (raft_t r );
90
+ raft_bool_t raft_is_leader (raft_t r );
89
91
90
92
// Returns the id of the current leader, or NOBODY if no leader.
91
93
int raft_get_leader (raft_t r );