Skip to content

Commit

Permalink
changes from ismail's comments + remove header time check
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivani912 committed Jul 23, 2020
1 parent d51a025 commit 68188bc
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions light-client/src/predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,11 @@ pub trait VerificationPredicates: Send {
/// Check that the trusted header is within the trusting period, adjusting for clock drift.
fn is_within_trust_period(
&self,
header: &Header,
trusted_header: &Header,
trusting_period: Duration,
clock_drift: Duration,
now: Time,
) -> Result<(), VerificationError> {
ensure!(
header.time < now + clock_drift,
VerificationError::HeaderFromTheFuture {
header_time: header.time,
now
}
);

let expires_at = header.time + trusting_period;
let expires_at = trusted_header.time + trusting_period;
ensure!(
expires_at > now,
VerificationError::NotWithinTrustPeriod { expires_at, now }
Expand All @@ -123,14 +114,14 @@ pub trait VerificationPredicates: Send {
/// Check that the untrusted header is from past.
fn is_header_from_past(
&self,
header: &Header,
untrusted_header: &Header,
clock_drift: Duration,
now: Time,
) -> Result<(), VerificationError> {
ensure!(
header.time < now + clock_drift,
untrusted_header.time < now + clock_drift,
VerificationError::HeaderFromTheFuture {
header_time: header.time,
header_time: untrusted_header.time,
now
}
);
Expand Down Expand Up @@ -245,7 +236,6 @@ pub fn verify(
vp.is_within_trust_period(
&trusted.signed_header.header,
options.trusting_period,
options.clock_drift,
now,
)?;

Expand Down

0 comments on commit 68188bc

Please sign in to comment.