@ -636,6 +636,7 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID,
}
talliedVotingPower := int64 ( 0 )
votingPowerNeeded := vals . TotalVotingPower ( ) * 2 / 3
for idx , commitSig := range commit . Signatures {
if commitSig . Absent ( ) {
continue // OK, some signatures can be absent.
@ -658,13 +659,15 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID,
// It's OK that the BlockID doesn't match. We include stray
// signatures (~votes for nil) to measure validator availability.
// }
}
if got , needed := talliedVotingPower , vals . TotalVotingPower ( ) * 2 / 3 ; got <= needed {
return ErrNotEnoughVotingPowerSigned { Got : got , Needed : needed }
// return as soon as +2/3 of the signatures are verified
if talliedVotingPower > votingPowerNeeded {
return nil
}
}
return nil
// talliedVotingPower <= needed, thus return error
return ErrNotEnoughVotingPowerSigned { Got : talliedVotingPower , Needed : votingPowerNeeded }
}
// VerifyFutureCommit will check to see if the set would be valid with a different
@ -762,6 +765,7 @@ func (vals *ValidatorSet) VerifyCommitTrusting(chainID string, blockID BlockID,
var (
talliedVotingPower int64
seenVals = make ( map [ int ] int , len ( commit . Signatures ) ) // validator index -> commit index
votingPowerNeeded = ( vals . TotalVotingPower ( ) * trustLevel . Numerator ) / trustLevel . Denominator
)
for idx , commitSig := range commit . Signatures {
@ -795,16 +799,14 @@ func (vals *ValidatorSet) VerifyCommitTrusting(chainID string, blockID BlockID,
// It's OK that the BlockID doesn't match. We include stray
// signatures (~votes for nil) to measure validator availability.
// }
}
}
got := talliedVotingPower
needed := ( vals . TotalVotingPower ( ) * trustLevel . Numerator ) / trustLevel . Denominator
if got <= needed {
return ErrNotEnoughVotingPowerSigned { Got : got , Needed : needed }
if talliedVotingPower > votingPowerNeeded {
return nil
}
}
}
return nil
return ErrNotEnoughVotingPowerSigned { Got : talliedVotingPower , Needed : votingPowerNeeded }
}
func verifyCommitBasic ( commit * Commit , height int64 , blockID BlockID ) error {