|
@@ -123,7 +123,7 @@ func (l *raftLog) append(after uint64, ents ...pb.Entry) uint64 {
|
|
|
func (l *raftLog) findConflict(from uint64, ents []pb.Entry) uint64 {
|
|
func (l *raftLog) findConflict(from uint64, ents []pb.Entry) uint64 {
|
|
|
// TODO(xiangli): validate the index of ents
|
|
// TODO(xiangli): validate the index of ents
|
|
|
for i, ne := range ents {
|
|
for i, ne := range ents {
|
|
|
- if oe := l.at(from + uint64(i)); oe == nil || oe.Term != ne.Term {
|
|
|
|
|
|
|
+ if !l.matchTerm(from+uint64(i), ne.Term) {
|
|
|
return from + uint64(i)
|
|
return from + uint64(i)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -254,14 +254,6 @@ func (l *raftLog) restore(s pb.Snapshot) {
|
|
|
l.unstableEnts = nil
|
|
l.unstableEnts = nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (l *raftLog) at(i uint64) *pb.Entry {
|
|
|
|
|
- ents := l.slice(i, i+1)
|
|
|
|
|
- if len(ents) == 0 {
|
|
|
|
|
- return nil
|
|
|
|
|
- }
|
|
|
|
|
- return &ents[0]
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// slice returns a slice of log entries from lo through hi-1, inclusive.
|
|
// slice returns a slice of log entries from lo through hi-1, inclusive.
|
|
|
func (l *raftLog) slice(lo uint64, hi uint64) []pb.Entry {
|
|
func (l *raftLog) slice(lo uint64, hi uint64) []pb.Entry {
|
|
|
if lo >= hi {
|
|
if lo >= hi {
|