mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
light: ensure trust level is strictly less than 1 (#6447)
This commit is contained in:
@@ -167,10 +167,10 @@ func Verify(
|
||||
|
||||
// ValidateTrustLevel checks that trustLevel is within the allowed range [1/3,
|
||||
// 1]. If not, it returns an error. 1/3 is the minimum amount of trust needed
|
||||
// which does not break the security model.
|
||||
// which does not break the security model. Must be strictly less than 1.
|
||||
func ValidateTrustLevel(lvl tmmath.Fraction) error {
|
||||
if lvl.Numerator*3 < lvl.Denominator || // < 1/3
|
||||
lvl.Numerator > lvl.Denominator || // > 1
|
||||
lvl.Numerator >= lvl.Denominator || // >= 1
|
||||
lvl.Denominator == 0 {
|
||||
return fmt.Errorf("trustLevel must be within [1/3, 1], given %v", lvl)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user