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
63
64
65
66
67
68
use fmt;
use DisplayOptionExt;
use crateRaftTypeConfig;
use crateVote;
use crateLogIdOf;
/// State of the most recently flushed log I/O operation.
///
/// This represents the durable state of the log storage after a flush completes. It includes:
/// - The vote(leader) under which the I/O was submitted
/// - The last log entry that was written (if any logs were appended)
///
/// # Ordering
///
/// Ordered lexicographically as `(vote, last_log_id)`, by the `PartialOrd` of [`Vote`] and of
/// `Option<LogId>`. This is a partial order:
/// - The votes compare first, and a strictly greater vote decides the result whatever the logs: a
/// flush point under a newer vote is greater even when its `last_log_id` is `None`.
/// - Votes of different terms compare by term. Within a term the configured leader id decides: with
/// [`leader_id_std`], two uncommitted votes of different nodes are incomparable, so
/// `partial_cmp()` returns `None`; with [`leader_id_adv`], the higher node id is greater. A
/// committed vote is greater than an uncommitted one with the same or an incomparable leader id.
/// - Under equal votes the log ids decide: `None` is less than any log id, and log ids compare
/// their committed leader id before their index, so a log of term 2 at index 1 is greater than
/// one of term 1 at index 100.
///
/// This lets `wait_until_ge()` wait for a progress milestone. Because a greater vote alone meets
/// the target, a caller that waits for a log entry also checks the vote and the log id it gets
/// back; see [`Raft::watch_log_progress()`].
///
/// [`leader_id_std`]: crate::impls::leader_id_std
/// [`leader_id_adv`]: crate::impls::leader_id_adv
/// [`Raft::watch_log_progress()`]: crate::Raft::watch_log_progress
///
/// # Special Cases
///
/// - `!vote.is_committed() && last_log_id.is_none()`: A candidate's vote is accepted but it has not
/// yet become leader (no AppendEntries received).