raft: fixed some typos and simplify minor logic

This commit is contained in:
Wine93
2019-08-23 01:44:49 +00:00
parent f4dfd1976d
commit 5f42161750
3 changed files with 8 additions and 8 deletions

View File

@@ -367,7 +367,7 @@ func newRaft(c *Config) *raft {
}
assertConfStatesEquivalent(r.logger, cs, r.switchToConfig(cfg, prs))
if !isHardStateEqual(hs, emptyState) {
if !IsEmptyHardState(hs) {
r.loadState(hs)
}
if c.Applied > 0 {
@@ -1099,7 +1099,7 @@ func stepLeader(r *raft, m pb.Message) error {
case ReadOnlyLeaseBased:
ri := r.raftLog.committed
if m.From == None || m.From == r.id { // from local member
r.readStates = append(r.readStates, ReadState{Index: r.raftLog.committed, RequestCtx: m.Entries[0].Data})
r.readStates = append(r.readStates, ReadState{Index: ri, RequestCtx: m.Entries[0].Data})
} else {
r.send(pb.Message{To: m.From, Type: pb.MsgReadIndexResp, Index: ri, Entries: m.Entries})
}