@ -198,29 +198,38 @@ captured by the `hasExpired` function that depends on trusted period (`tp`) and
not considered expired.
```go
func hasExpired(h) {
// return true if header has expired, i.e., it is outside its trusted period; otherwise it returns false
func hasExpired(h) bool {
if h.Header.bfttime + tp - Delta <now{//Observation1
return true
}
// basic validation (function `verify`) has already been called on h2
func CheckSupport(h1,h2,trustlevel) bool {
if hasExpired(h1) then return false //old header was once trusted but it is expired
vp_all := totalVotingPower(h1.Header.NextV)
// total sum of voting power of validators in h1
if h2.Header.height == h1.Header.height + 1 {
// specific check for adjacent headers
if h1.Header.NextV == h2.Header.V then
return hasExpired(h2)
}
}
// return true if header is correctly signed by 2/3+ voting power in the corresponding validator set; otherwise false. Additional checks should be done in the implementation
// to ensure header is well formed.
func verify(h) bool {
vp_all := totalVotingPower(h.Header.V) // total sum of voting power of validators in h
// validators that signed h2 are more than a third of voting power in h1
if (votingpower_in(signers(h2.Commit),h1.Header.NextV) > max(1/3,trustlevel) * vp_all) {
return hasExpired(h2)
}
// Captures skipping condition. h1 and h2 has already passed basic validation (function `verify`).
// returns (true, nil) in case h2 can be trusted based on h1, (false, nil) in case it cannot be trusted but no errors are observed during check and (false, error) in case
// an error is detected (for example adjacent headers are not consistent).