// RecoverChange recovers an update from a change record. func (this *Paxos) RecoverChange(lsn wal.LSN, uid string, data []byte) error { if lsn == nil { // We reached end of wal recovery, figure out the current state and resume // any inflight operations. _ = this.Refresh() return nil } if uid != this.uid { this.Errorf("change record doesn't belong to this instance") return errs.ErrInvalid } walRecord := thispb.WALRecord{} if err := proto.Unmarshal(data, &walRecord); err != nil { this.Errorf("could not parse change record: %v", err) return err } switch { case walRecord.ConfigChange != nil: return this.doUpdateConfig(walRecord.GetConfigChange()) case walRecord.ProposerChange != nil: return this.doUpdateProposer(walRecord.GetProposerChange()) case walRecord.AcceptorChange != nil: return this.doUpdateAcceptor(walRecord.GetAcceptorChange()) case walRecord.LearnerChange != nil: return this.doUpdateLearner(walRecord.GetLearnerChange()) default: this.Errorf("invalid/corrupt wal change record: %s", walRecord) return errs.ErrCorrupt } return nil }