func (this *Paxos) doGetNextProposalBallot() (int64, error) { nextProposalBallot := this.proposalBallot if this.proposalBallot < 0 { nextProposalBallot = int64(this.proposerIndex) } else { nextProposalBallot += int64(len(this.proposerList)) } change := thispb.ProposerChange{} change.ProposalBallot = proto.Int64(nextProposalBallot) if err := this.doUpdateProposer(&change); err != nil { this.Errorf("could not update the proposer state: %v", err) return -1, err } return this.proposalBallot, nil }
func (this *Paxos) doUpdateProposer(change *thispb.ProposerChange) error { if !this.wal.IsRecovering() { walRecord := thispb.WALRecord{} walRecord.ProposerChange = change _, errSync := wal.SyncChangeProto(this.wal, this.uid, &walRecord) if errSync != nil { this.Errorf("could not write proposer change record: %v", errSync) return errSync } } if change.ProposalBallot != nil { ballot := change.GetProposalBallot() if this.proposalBallot < ballot { this.proposalBallot = ballot } } return nil }