ames: 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.
This commit is contained in:
Fang 2020-06-25 20:20:57 +02:00
parent ed808614aa
commit b224ac0878
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
2 changed files with 24 additions and 23 deletions

View File

@ -491,11 +491,11 @@
++ v-ames ++ v-ames
|% |%
++ peers ++ peers
(scry (map ship ?(%alien %known)) %a %peers ~) (scry (map ship ?(%alien %known)) %ax %$ /peers)
:: ::
++ peer ++ peer
|= who=ship |= who=ship
(scry ship-state:ames %a %peer /(scot %p who)) (scry ship-state:ames %ax %$ /peers/(scot %p who))
:: ::
++ peer-to-json ++ peer-to-json
=, ames =, ames

View File

@ -691,35 +691,37 @@
-- --
:: +scry: dereference namespace :: +scry: dereference namespace
:: ::
:: The ones producing vases are expected to be used like this:
::
:: &tang [(sell .^(vase %a /=peer=/~zod)) ~]
::
++ scry ++ scry
|= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] |= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path]
^- (unit (unit cage)) ^- (unit (unit cage))
?. =(lot [%$ %da now]) ~ :: only respond for the local identity, %$ desk, current timestamp
?. =(%$ ren) [~ ~] ::
?. =([%& our] why) ?. ?& =(&+our why)
[~ ~] =([%$ %da now] lot)
?+ syd ~ =(%$ syd)
%peers ==
?^ tyl [~ ~] ~
:: /ax/peers (map ship ?(%alien known))
:: /ax/peers/[ship] ship-state
:: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)]
:: /ax/snd-bones/[ship]/[bone] vase
::
?. ?=(%x ren) ~
?+ tyl [~ ~]
[%peers ~]
:^ ~ ~ %noun :^ ~ ~ %noun
!> ^- (map ship ?(%alien %known)) !> ^- (map ship ?(%alien %known))
(~(run by peers.ames-state) head) (~(run by peers.ames-state) head)
:: ::
%peer [%peers @ ~]
?. ?=([@ ~] tyl) [~ ~] =/ who (slaw %p i.t.tyl)
=/ who (slaw %p i.tyl)
?~ who [~ ~] ?~ who [~ ~]
?~ peer=(~(get by peers.ames-state) u.who) ?~ peer=(~(get by peers.ames-state) u.who)
[~ ~] [~ ~]
``noun+!>(u.peer) ``noun+!>(u.peer)
:: ::
%bones [%bones @ ~]
?. ?=([@ ~] tyl) [~ ~] =/ who (slaw %p i.t.tyl)
=/ who (slaw %p i.tyl)
?~ who [~ ~] ?~ who [~ ~]
=/ per (~(get by peers.ames-state) u.who) =/ per (~(get by peers.ames-state) u.who)
?. ?=([~ %known *] per) [~ ~] ?. ?=([~ %known *] per) [~ ~]
@ -728,11 +730,10 @@
[snd=~(key by snd) rcv=~(key by rcv)] [snd=~(key by snd) rcv=~(key by rcv)]
``noun+!>(res) ``noun+!>(res)
:: ::
%snd-bone [%snd-bones @ @ ~]
?. ?=([@ @ ~] tyl) [~ ~] =/ who (slaw %p i.t.tyl)
=/ who (slaw %p i.tyl)
?~ who [~ ~] ?~ who [~ ~]
=/ ost (slaw %ud i.t.tyl) =/ ost (slaw %ud i.t.t.tyl)
?~ ost [~ ~] ?~ ost [~ ~]
=/ per (~(get by peers.ames-state) u.who) =/ per (~(get by peers.ames-state) u.who)
?. ?=([~ %known *] per) [~ ~] ?. ?=([~ %known *] per) [~ ~]