示例#1
0
文件: ballot.go 项目: chang290/server
func (ballot *Ballot) CreateBadReadCap(txnId *common.TxnId, actions *msgs.Action_List) {
	seg := capn.NewBuffer(nil)
	voteCap := msgs.NewVote(seg)
	voteCap.SetAbortBadRead()
	badReadCap := voteCap.AbortBadRead()
	badReadCap.SetTxnId(txnId[:])
	badReadCap.SetTxnActions(*actions)
	ballot.VoteCap = &voteCap
	ballot.Vote = AbortBadRead
}
示例#2
0
文件: ballot.go 项目: chang290/server
func (ballot *Ballot) AddToSeg(seg *capn.Segment) msgs.Ballot {
	ballotCap := msgs.NewBallot(seg)
	ballotCap.SetVarId(ballot.VarUUId[:])
	ballotCap.SetClock(ballot.Clock.AddToSeg(seg))

	if ballot.VoteCap == nil {
		voteCap := msgs.NewVote(seg)
		ballot.VoteCap = &voteCap
		switch ballot.Vote {
		case Commit:
			voteCap.SetCommit()
		case AbortDeadlock:
			voteCap.SetAbortDeadlock()
		case AbortBadRead:
			voteCap.SetAbortBadRead()
		}
	}

	ballotCap.SetVote(*ballot.VoteCap)
	ballot.BallotCap = &ballotCap
	return ballotCap
}