@@ -106,23 +106,25 @@ func (l *raftLog) String() string {
106
106
107
107
// maybeAppend returns (0, false) if the entries cannot be appended. Otherwise,
108
108
// it returns (last index of new entries, true).
109
- func (l * raftLog ) maybeAppend (prev entryID , committed uint64 , ents ... pb. Entry ) (lastnewi uint64 , ok bool ) {
110
- if ! l .matchTerm (prev ) {
109
+ func (l * raftLog ) maybeAppend (a logSlice , committed uint64 ) (lastnewi uint64 , ok bool ) {
110
+ if ! l .matchTerm (a . prev ) {
111
111
return 0 , false
112
112
}
113
+ // TODO(pav-kv): propagate logSlice down the stack. It will be used all the
114
+ // way down in unstable, for safety checks, and for useful bookkeeping.
113
115
114
- lastnewi = prev .index + uint64 (len (ents ))
115
- ci := l .findConflict (ents )
116
+ lastnewi = a . prev .index + uint64 (len (a . entries ))
117
+ ci := l .findConflict (a . entries )
116
118
switch {
117
119
case ci == 0 :
118
120
case ci <= l .committed :
119
121
l .logger .Panicf ("entry %d conflict with committed entry [committed(%d)]" , ci , l .committed )
120
122
default :
121
- offset := prev .index + 1
122
- if ci - offset > uint64 (len (ents )) {
123
- l .logger .Panicf ("index, %d, is out of range [%d]" , ci - offset , len (ents ))
123
+ offset := a . prev .index + 1
124
+ if ci - offset > uint64 (len (a . entries )) {
125
+ l .logger .Panicf ("index, %d, is out of range [%d]" , ci - offset , len (a . entries ))
124
126
}
125
- l .append (ents [ci - offset :]... )
127
+ l .append (a . entries [ci - offset :]... )
126
128
}
127
129
l .commitTo (min (committed , lastnewi ))
128
130
return lastnewi , true
0 commit comments