mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: add Entry.isConfig
This commit is contained in:
@@ -13,6 +13,10 @@ type Entry struct {
|
||||
Data []byte
|
||||
}
|
||||
|
||||
func (e *Entry) isConfig() bool {
|
||||
return e.Type == AddNode || e.Type == RemoveNode
|
||||
}
|
||||
|
||||
type log struct {
|
||||
ents []Entry
|
||||
committed int
|
||||
|
||||
@@ -227,7 +227,7 @@ func (sm *stateMachine) becomeLeader() {
|
||||
sm.state = stateLeader
|
||||
|
||||
for _, e := range sm.log.ents[sm.log.committed:] {
|
||||
if e.Type == AddNode || e.Type == RemoveNode {
|
||||
if e.isConfig() {
|
||||
sm.pendingConf = true
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func (sm *stateMachine) Step(m Message) (ok bool) {
|
||||
switch sm.lead {
|
||||
case sm.id:
|
||||
e := m.Entries[0]
|
||||
if e.Type == AddNode || e.Type == RemoveNode {
|
||||
if e.isConfig() {
|
||||
if sm.pendingConf {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user