Esempio n. 1
0
File: paxos.go Progetto: bvk/ascent
func (this *Paxos) doRestoreLearner(state *thispb.LearnerState) {
	if state.ChosenValue != nil {
		this.chosenValue = state.GetChosenValue()
		return
	}

	for index := range state.VotedBallotList {
		ballot := state.VotedBallotList[index]
		value := state.VotedValueList[index]
		acceptor := state.VotedAcceptorList[index]

		// Ballot numbers can repeat in the list, but corresponding value is stored
		// only once. So, we may find nils in the state.VotedValueList.
		if value != nil {
			this.ballotValueMap[ballot] = value
		}

		acceptorSet, found := this.ballotAcceptorsMap[ballot]
		if !found {
			acceptorSet = make(map[string]struct{})
			this.ballotAcceptorsMap[ballot] = acceptorSet
		}
		acceptorSet[acceptor] = struct{}{}
	}
}