Ejemplo n.º 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
}
Ejemplo n.º 2
0
func BallotFromCap(ballotCap *msgs.Ballot) *Ballot {
	voteCap := ballotCap.Vote()
	ballot := &Ballot{
		VarUUId:   common.MakeVarUUId(ballotCap.VarId()),
		Clock:     VectorClockFromCap(ballotCap.Clock()),
		Vote:      Vote(voteCap.Which()),
		BallotCap: ballotCap,
		VoteCap:   &voteCap,
	}
	return ballot
}