Source Code

(define-constant O tx-sender)
(define-constant E1 (err u740))
(define-constant E2 (err u741))
(define-constant E3 (err u742))
(define-map schedules uint {start: uint, end: uint, extended: bool})
(define-public (set-schedule (mid uint) (start uint) (end uint))
 (begin (asserts! (is-eq tx-sender O) E1)
  (asserts! (> end start) E2)
  (ok (map-set schedules mid {start: start, end: end, extended: false}))))
(define-public (extend-deadline (mid uint) (extra uint))
 (let ((s (unwrap! (map-get? schedules mid) E3)))
  (asserts! (is-eq tx-sender O) E1)
  (ok (map-set schedules mid
   (merge s {end: (+ (get end s) extra), extended: true})))))
(define-read-only (get-schedule (mid uint))
 (map-get? schedules mid))
(define-read-only (is-active (mid uint))
 (match (map-get? schedules mid)
  s (and (>= stacks-block-height (get start s))
         (< stacks-block-height (get end s)))
  false))
(define-read-only (blocks-remaining (mid uint))
 (match (map-get? schedules mid)
  s (if (> (get end s) stacks-block-height)
     (- (get end s) stacks-block-height) u0)
  u0))

Functions (5)

FunctionAccessArgs
set-schedulepublicmid: uint, start: uint, end: uint
extend-deadlinepublicmid: uint, extra: uint
get-scheduleread-onlymid: uint
is-activeread-onlymid: uint
blocks-remainingread-onlymid: uint