diff --git a/zonedb.rkt b/zonedb.rkt index 1bed798..e4a72ab 100644 --- a/zonedb.rkt +++ b/zonedb.rkt @@ -29,7 +29,7 @@ bit-string->zone) (define-type RelativeSeconds Real) -(define-type AbsoluteSeconds Nonnegative-Real) +(define-type AbsoluteSeconds Real) (define-predicate absolute-seconds? AbsoluteSeconds) ;; An InfiniteLifetime is an (infinite-lifetime RelativeSeconds), a @@ -60,7 +60,7 @@ (: current-inexact-seconds : -> AbsoluteSeconds) (define (current-inexact-seconds) - (cast (/ (current-inexact-milliseconds) 1000.0) AbsoluteSeconds)) + (/ (current-inexact-milliseconds) 1000.0)) (: still-valid? : Expiry AbsoluteSeconds -> Boolean) (define (still-valid? expiry now) @@ -304,5 +304,7 @@ ([ (rr0 :: (t:rr empty-packet)) (= 1) (ttl :: bits 32) (rest :: binary) ] (loop ((incorporate-rr #f) (struct-copy rr rr0 [ttl ttl]) db) rest)) ([ (rr0 :: (t:rr empty-packet)) (= 0) (expirytime :: bits 32) (rest :: binary) ] - (define new-ttl (cast (exact-floor (- expirytime now)) Nonnegative-Integer)) - (loop ((incorporate-rr now) (struct-copy rr rr0 [ttl new-ttl]) db) rest))))) + (define new-ttl (exact-floor (- expirytime now))) + (if (negative? new-ttl) + (loop db rest) + (loop ((incorporate-rr now) (struct-copy rr rr0 [ttl new-ttl]) db) rest))))))