(define-constant BLOCKS-PER-DAY u144)
(define-map streaks principal {current: uint, best: uint, last-block: uint})
(define-public (check-in)
(let ((s (default-to {current: u0, best: u0, last-block: u0}
(map-get? streaks tx-sender)))
(gap (- stacks-block-height (get last-block s))))
(let ((new-streak (if (<= gap BLOCKS-PER-DAY) (+ (get current s) u1) u1))
(new-best (if (> new-streak (get best s)) new-streak (get best s))))
(ok (map-set streaks tx-sender
{current: new-streak, best: new-best, last-block: stacks-block-height})))))
(define-read-only (get-streak (u principal))
(default-to {current: u0, best: u0, last-block: u0}
(map-get? streaks u)))