@@ -215,6 +215,7 @@ struct raft_request_vote
215
215
raft_index last_log_term ; /* Term of log entry at last_log_index. */
216
216
bool disrupt_leader ; /* True if current leader should be discarded. */
217
217
bool pre_vote ; /* True if this is a pre-vote request. */
218
+ uint64_t reserved [8 ]; /* Future use */
218
219
};
219
220
220
221
/**
@@ -225,6 +226,7 @@ struct raft_request_vote_result
225
226
raft_term term ; /* Receiver's current term (candidate updates itself). */
226
227
bool vote_granted ; /* True means candidate received vote. */
227
228
raft_tribool pre_vote ; /* The response to a pre-vote RequestVote or not. */
229
+ uint64_t reserved [8 ]; /* Future use */
228
230
};
229
231
230
232
/**
@@ -241,6 +243,7 @@ struct raft_append_entries
241
243
raft_index leader_commit ; /* Leader's commit index. */
242
244
struct raft_entry * entries ; /* Log entries to append. */
243
245
unsigned n_entries ; /* Size of the log entries array. */
246
+ uint64_t reserved [8 ]; /* Future use */
244
247
};
245
248
246
249
/**
@@ -251,6 +254,7 @@ struct raft_append_entries_result
251
254
raft_term term ; /* Receiver's current_term. */
252
255
raft_index rejected ; /* If non-zero, the index that was rejected. */
253
256
raft_index last_log_index ; /* Receiver's last log entry index, as hint. */
257
+ uint64_t reserved [8 ]; /* Future use */
254
258
};
255
259
256
260
/**
@@ -264,6 +268,7 @@ struct raft_install_snapshot
264
268
struct raft_configuration conf ; /* Config as of last_index. */
265
269
raft_index conf_index ; /* Commit index of conf. */
266
270
struct raft_buffer data ; /* Raw snapshot data. */
271
+ uint64_t reserved [8 ]; /* Future use */
267
272
};
268
273
269
274
/**
@@ -277,6 +282,7 @@ struct raft_timeout_now
277
282
raft_term term ; /* Leader's term. */
278
283
raft_index last_log_index ; /* Index of leader's last log entry. */
279
284
raft_index last_log_term ; /* Term of log entry at last_log_index. */
285
+ uint64_t reserved [8 ]; /* Future use */
280
286
};
281
287
282
288
/**
@@ -293,6 +299,22 @@ enum {
293
299
294
300
/**
295
301
* A single RPC message that can be sent or received over the network.
302
+ *
303
+ * Updating to a new version of an RPC message is done based on the encoded size
304
+ * of the message, see e.g. `sizeofRequestVoteV1` in uv_encoding.c
305
+ *
306
+ * The RPC message types all have a `reserved` field. When extending such a
307
+ * struct, and thus shrinking the `reserved` array, one should be careful not to
308
+ * give meaning the `zero` value because the raft implementation needs to know
309
+ * whether to other side knows the new field or not. `zero` means the other side
310
+ * does not know the new field/functionality (this is why raft_tribool exists).
311
+ * Implementers MUST always zero out unknown fields before passing them to raft.
312
+ *
313
+ * Adding a new message to the union is supported, as long as its size is
314
+ * smaller than the largest struct in the union, which should be plenty.
315
+ * TODO: Add a compile-time check to verify this once a new message is actually
316
+ * needed.
317
+ *
296
318
*/
297
319
struct raft_message
298
320
{
@@ -307,6 +329,7 @@ struct raft_message
307
329
struct raft_install_snapshot install_snapshot ;
308
330
struct raft_timeout_now timeout_now ;
309
331
};
332
+ uint64_t reserved [8 ]; /* Future use */
310
333
};
311
334
312
335
/**
0 commit comments