github.com/okex/exchain@v1.8.0/libs/tendermint/lite2/ibc_verify.go (about) 1 package lite 2 3 import ( 4 "time" 5 6 tmmath "github.com/okex/exchain/libs/tendermint/libs/math" 7 "github.com/okex/exchain/libs/tendermint/types" 8 ) 9 10 func IBCVerify( 11 chainID string, 12 trustedHeader *types.SignedHeader, // height=X 13 trustedVals *types.ValidatorSet, // height=X or height=X+1 14 untrustedHeader *types.SignedHeader, // height=Y 15 untrustedVals *types.ValidatorSet, // height=Y 16 trustingPeriod time.Duration, 17 now time.Time, 18 maxClockDrift time.Duration, 19 trustLevel tmmath.Fraction) error { 20 21 if untrustedHeader.Height != trustedHeader.Height+1 { 22 return IBCVerifyNonAdjacent(chainID, trustedHeader, trustedVals, untrustedHeader, untrustedVals, 23 trustingPeriod, now, maxClockDrift, trustLevel) 24 } 25 26 return IBCVerifyAdjacent(chainID, trustedHeader, untrustedHeader, untrustedVals, trustingPeriod, now, maxClockDrift) 27 } 28 29 func IBCVerifyNonAdjacent( 30 chainID string, 31 trustedHeader *types.SignedHeader, // height=X 32 trustedVals *types.ValidatorSet, // height=X or height=X+1 33 untrustedHeader *types.SignedHeader, // height=Y 34 untrustedVals *types.ValidatorSet, // height=Y 35 trustingPeriod time.Duration, 36 now time.Time, 37 maxClockDrift time.Duration, 38 trustLevel tmmath.Fraction) error { 39 40 return commonVerifyNonAdjacent( 41 chainID, trustedHeader, trustedVals, untrustedHeader, 42 untrustedVals, trustingPeriod, now, maxClockDrift, trustLevel, true) 43 } 44 45 func IBCVerifyAdjacent( 46 chainID string, 47 trustedHeader *types.SignedHeader, // height=X 48 untrustedHeader *types.SignedHeader, // height=X+1 49 untrustedVals *types.ValidatorSet, // height=X+1 50 trustingPeriod time.Duration, 51 now time.Time, 52 maxClockDrift time.Duration) error { 53 54 return commonVerifyAdjacent( 55 chainID, 56 trustedHeader, // height=X 57 untrustedHeader, // height=X+1 58 untrustedVals, // height=X+1 59 trustingPeriod, 60 now, 61 maxClockDrift, true) 62 }