// check if there are enough justifications to justify another prevote given a quorum
check if there are enough justifications to justify another prevote given a quorum
// check if there are enough justifications to justify another prevote given a quorum
func (acc *Accountability) checkQuorumJustificationsForPrevote(hvs *common.HeightVoteSet, lockedValue *common.Value, lockedRound int64, prevote *common.Message) bool {
	if uint64(len(prevote.Justifications)) < acc.getQuorumThreshold() {
		return false
	}
	for _, justification := range prevote.Justifications {
		if !(justification.Round < prevote.Round &&
			(int64(justification.Round) >= lockedRound || lockedValue.Equal(prevote.Value))) {
			return false
		}
		vs, vsLoaded := hvs.VoteSetMap[justification.Round]
		if vs == nil || !vsLoaded {
			return false
		}
		foundJustification := false
		for _, receivedPrevoteMessage := range vs.ReceivedPrevoteMessages {
			if receivedPrevoteMessage.Value != nil && receivedPrevoteMessage.Value.Equal(prevote.Value) && justification.Equal(receivedPrevoteMessage) {
				foundJustification = true
				break
			}
		}
		if !foundJustification {
			return false
		}
	}
	return true
}
func ( acc * Accountability ) checkQuorumJustificationsForPrevote ( hvs * common . HeightVoteSet , lockedValue * common . Value , lockedRound int64 , prevote * common . Message ) bool { if uint64 ( len ( prevote . Justifications ) ) < acc . getQuorumThreshold ( ) { return false } for _ , justification := range prevote . Justifications { if ! ( justification . Round < prevote . Round && ( int64 ( justification . Round ) >= lockedRound || lockedValue . Equal ( prevote . Value ) ) ) { return false } vs , vsLoaded := hvs . VoteSetMap [ justification . Round ] if vs == nil || ! vsLoaded { return false } foundJustification := false for _ , receivedPrevoteMessage := range vs . ReceivedPrevoteMessages { if receivedPrevoteMessage . Value != nil && receivedPrevoteMessage . Value . Equal ( prevote . Value ) && justification . Equal ( receivedPrevoteMessage ) { foundJustification = true break } } if ! foundJustification { return false } } return true }
check if there are enough justifications to justify another prevote given a quorum
check if there are enough justifications to justify another prevote given a quorum
// if not enough justifications, the process is faulty // go over all justifications provided and check that each one exists and is appropriate // if it's not between the lockedRound and the current round, it's not valid according to the consensus algorithm // load vote set // if vote set not present, the justification is not real and, thus, not valid // find the justification and check that is equal to the one contained in the prevote message and corresponds to the same value // if not found, justification is fake