// findConflict finds the index of the conflict.
// It returns the first pair of conflicting entries between the existing
// entries and the given entries, if there are any.
// If there is no conflicting entries, and the existing entries contains
// all the given entries, zero will be returned.
// If there is no conflicting entries, but the given entries contains new
// entries, the index of the first new entry will be returned.
// An entry is considered to be conflicting if it has the same index but
// a different term.
// The first entry MUST have an index equal to the argument 'from'.
// The index of the given entries MUST be continuously increasing.
func(l*raftLog)findConflict(ents[]pb.Entry)uint64{for_,ne:=rangeents{if!l.matchTerm(ne.Index,ne.Term){ifne.Index<=l.lastIndex(){l.logger.Infof("found conflict at index %d [existing term: %d, conflicting term: %d]",ne.Index,l.zeroTermOnErrCompacted(l.term(ne.Index)),ne.Term)}returnne.Index}}return0}func(l*raftLog)unstableEntries()[]pb.Entry{iflen(l.unstable.entries)==0{returnnil}returnl.unstable.entries}