raft: use max in log.slice
parent
9ddd8ee539
commit
bdbafe2cf3
|
@ -285,12 +285,7 @@ func (l *raftLog) slice(lo uint64, hi uint64) []pb.Entry {
|
||||||
ents = append(ents, storedEnts...)
|
ents = append(ents, storedEnts...)
|
||||||
}
|
}
|
||||||
if len(l.unstableEnts) > 0 && hi > l.unstable {
|
if len(l.unstableEnts) > 0 && hi > l.unstable {
|
||||||
var firstUnstable uint64
|
firstUnstable := max(lo, l.unstable)
|
||||||
if lo < l.unstable {
|
|
||||||
firstUnstable = l.unstable
|
|
||||||
} else {
|
|
||||||
firstUnstable = lo
|
|
||||||
}
|
|
||||||
ents = append(ents, l.unstableEnts[firstUnstable-l.unstable:hi-l.unstable]...)
|
ents = append(ents, l.unstableEnts[firstUnstable-l.unstable:hi-l.unstable]...)
|
||||||
}
|
}
|
||||||
return ents
|
return ents
|
||||||
|
|
Loading…
Reference in New Issue