type Progress … // ResetState moves the Progress into the specified State, resetting ProbeSent, // PendingSnapshot, and Inflights. func (pr *Progress) ResetState(state StateType) { … } func max(a, b uint64) uint64 { … } func min(a, b uint64) uint64 { … } // ProbeAcked is called when this peer has accepted an append. It resets // ProbeSent to signal that additional append messages should be sent without // further delay. func (pr *Progress) ProbeAcked() { … } // BecomeProbe transitions into StateProbe. Next is reset to Match+1 or, // optionally and if larger, the index of the pending snapshot. func (pr *Progress) BecomeProbe() { … } // BecomeReplicate transitions into StateReplicate, resetting Next to Match+1. func (pr *Progress) BecomeReplicate() { … } // BecomeSnapshot moves the Progress to StateSnapshot with the specified pending // snapshot index. func (pr *Progress) BecomeSnapshot(snapshoti uint64) { … } // MaybeUpdate is called when an MsgAppResp arrives from the follower, with the // index acked by it. The method returns false if the given n index comes from // an outdated message. Otherwise it updates the progress and returns true. func (pr *Progress) MaybeUpdate(n uint64) bool { … } // OptimisticUpdate signals that appends all the way up to and including index n // are in-flight. As a result, Next is increased to n+1. func (pr *Progress) OptimisticUpdate(n uint64) { … } // MaybeDecrTo adjusts the Progress to the receipt of a MsgApp rejection. The // arguments are the index of the append message rejected by the follower, and // the hint that we want to decrease to. // // Rejections can happen spuriously as messages are sent out of order or // duplicated. In such cases, the rejection pertains to an index that the // Progress already knows were previously acknowledged, and false is returned // without changing the Progress. // // If the rejection is genuine, Next is lowered sensibly, and the Progress is // cleared for sending log entries. func (pr *Progress) MaybeDecrTo(rejected, matchHint uint64) bool { … } // IsPaused returns whether sending log entries to this node has been throttled. // This is done when a node has rejected recent MsgApps, is currently waiting // for a snapshot, or has reached the MaxInflightMsgs limit. In normal // operation, this is false. A throttled node will be contacted less frequently // until it has reached a state in which it's able to accept a steady stream of // log entries again. func (pr *Progress) IsPaused() bool { … } func (pr *Progress) String() string { … } type ProgressMap … // String prints the ProgressMap in sorted key order, one Progress per line. func (m ProgressMap) String() string { … }