Example #1
0
File: paxos.go Project: bvk/ascent
func (this *Paxos) doSaveAcceptor(state *thispb.AcceptorState) {
	state.PromisedBallot = proto.Int64(this.promisedBallot)
	state.VotedBallot = proto.Int64(this.votedBallot)
	state.VotedValue = append([]byte{}, this.votedValue...)
	for ballot, learnerSet := range this.learnerAckMap {
		for learner := range learnerSet {
			state.AckedBallotList = append(state.AckedBallotList, ballot)
			state.AckedLearnerList = append(state.AckedLearnerList, learner)
		}
	}
}
Example #2
0
File: paxos.go Project: bvk/ascent
func (this *Paxos) doRestoreAcceptor(state *thispb.AcceptorState) {
	this.promisedBallot = state.GetPromisedBallot()
	this.votedBallot = state.GetVotedBallot()
	this.votedValue = state.GetVotedValue()

	for index := range state.AckedBallotList {
		ballot := state.AckedBallotList[index]
		learner := state.AckedLearnerList[index]

		learnerSet, found := this.learnerAckMap[ballot]
		if !found {
			learnerSet = make(map[string]struct{})
			this.learnerAckMap[ballot] = learnerSet
		}
		learnerSet[learner] = struct{}{}
	}
}