From a94285208aa7fd97a40a3fb0935d3490dff84f92 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 24 Jun 2020 16:34:36 +0200 Subject: [PATCH] behn: improve scry interface No longer abuse the desk field, instead making use of the path. Reject any scries outside of the local ship, empty desk and current time as invalid. Expose ducts only under a debug endpoint, nothing else should care about being able to inspect them. Add scry endpoints for the very next timer (if any), and all timers up to and including a specified timestamp. --- pkg/arvo/app/dbug.hoon | 2 +- pkg/arvo/gen/timers.hoon | 4 ++-- pkg/arvo/sys/vane/behn.hoon | 45 ++++++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/dbug.hoon b/pkg/arvo/app/dbug.hoon index 90124315b..320a03dba 100644 --- a/pkg/arvo/app/dbug.hoon +++ b/pkg/arvo/app/dbug.hoon @@ -767,7 +767,7 @@ ++ v-behn |% ++ timers - (scry ,(list [date=@da =duct]) %b %timers ~) + (scry ,(list [date=@da =duct]) %bx %$ /debug/timers) -- :: :: clay diff --git a/pkg/arvo/gen/timers.hoon b/pkg/arvo/gen/timers.hoon index f53710f58..715104fda 100644 --- a/pkg/arvo/gen/timers.hoon +++ b/pkg/arvo/gen/timers.hoon @@ -1,5 +1,5 @@ :: Find list of currently running Behn timers :- %say -|= * +|= [[now=@da *] *] :- %tang -[>.^((list [date=@da =duct]) %b /=timers=)< ~] +[>.^((list [date=@da =duct]) %bx /=//(scot %da now)/debug/timers)< ~] diff --git a/pkg/arvo/sys/vane/behn.hoon b/pkg/arvo/sys/vane/behn.hoon index a9dcfa8b7..d5aaec0f9 100644 --- a/pkg/arvo/sys/vane/behn.hoon +++ b/pkg/arvo/sys/vane/behn.hoon @@ -389,18 +389,53 @@ ++ scry |= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] ^- (unit (unit cage)) + :: only respond for the local identity, %$ desk, current timestamp :: - ?. ?=(%& -.why) + ?. ?& =(&+our why) + =([%$ %da now] lot) + =(%$ syd) + == ~ - ?. ?=(%timers syd) - [~ ~] - =/ tiz=(list [@da duct]) + :: /bx/debug/timers (list [@da duct]) all timers and their ducts + :: /bx/timers (list @da) all timer timestamps + :: /bx/timers/next (unit @da) the very next timer to fire + :: /bx/timers/[da] (list @da) all timers up to and including da + :: + ?. ?=(%x ren) ~ + ?+ tyl [~ ~] + [%debug %timers ~] + :^ ~ ~ %noun + !> ^- (list [@da duct]) %- zing %+ turn (tap:timer-map timers) |= [date=@da q=(qeu duct)] %+ turn ~(tap to q) |=(d=duct [date d]) - [~ ~ %noun !>(tiz)] + :: + [%timers ~] + :^ ~ ~ %noun + !> ^- (list @da) + %- zing + %+ turn (tap:timer-map timers) + |= [date=@da q=(qeu duct)] + (reap ~(wyt in q) date) + :: + [%timers %next ~] + :^ ~ ~ %noun + !> ^- (unit @da) + (bind (peek:timer-map timers) head) + :: + [%timers @ ~] + ?~ til=(slaw %da i.t.tyl) + [~ ~] + :^ ~ ~ %noun + !> ^- (list @da) + %- zing + %+ turn (tap:timer-map timers) + |= [date=@da q=(qeu duct)] + ?: (gth date u.til) ~ + (reap ~(wyt in q) date) + == :: ++ stay state ++ take