Beispiel #1
0
func (twoA *proposalTwoA) addTwoAToAcceptRequest(seg *capn.Segment, acceptRequest *msgs.TxnVoteAcceptRequest, sender *proposalSender) bool {
	var ballotPtr *msgs.Ballot
	if twoA.winningBallot == nil { // free choice from everyone
		ballot := twoA.ballot.AddToSeg(seg)
		ballotPtr = &ballot
	} else {
		ballotPtr = twoA.winningBallot
	}
	acceptRequest.SetBallot(*ballotPtr)

	acceptRequest.SetRoundNumber(uint64(twoA.currentRoundNumber))
	twoA.twoASender = sender
	twoA.nextState(nil)
	return ballotPtr.Vote().Which() != msgs.VOTE_COMMIT
}
Beispiel #2
0
func (i *instance) TwoATxnVotesReceived(request *msgs.TxnVoteAcceptRequest) (accepted bool, rejected bool) {
	roundNumber := paxosNumber(request.RoundNumber())
	if roundNumber == i.acceptedNum && i.accepted != nil {
		// duplicate 2a. Don't issue any response.
		return
	} else if roundNumber >= i.promiseNum || i.promiseNum == 0 {
		i.promiseNum = roundNumber
		i.acceptedNum = roundNumber
		ballot := request.Ballot()
		i.accepted = &ballot
		accepted = true
		return
	} else {
		rejected = true
		return
	}
}