urbit/pkg/arvo/sys/vane/khan.hoon

137 lines
3.1 KiB
Plaintext
Raw Normal View History

2022-01-21 21:48:05 +03:00
:: %khan, thread runner
!:
!? 164
::
|= our=ship
=> |%
+$ move [p=duct q=(wite note gift:khan)]
+$ note :: out request $->
2022-01-26 02:37:48 +03:00
$~ [%g %deal *sock *term *deal:gall]
2022-01-22 04:46:59 +03:00
$% $: %g :: to %gall
$>(%deal task:gall) :: full transmission
== == ::
2022-01-21 21:48:05 +03:00
+$ sign :: in response $<-
$% $: %gall
$>(%unto gift:gall)
==
$: %khan
$>(%avow gift:khan)
== ==
2022-01-21 21:48:05 +03:00
+$ khan-state
$: %0
unix-duct=duct
==
--
2022-01-22 04:46:59 +03:00
=>
|%
++ start-spider
2022-01-26 02:37:48 +03:00
|= [our=@p =cage]
^- note
[%g %deal [our our] %spider %poke cage]
2022-01-22 04:46:59 +03:00
++ watch-spider
2022-01-26 02:37:48 +03:00
|= [our=@p =path]
^- note
[%g %deal [our our] %spider %watch path]
2022-01-22 04:46:59 +03:00
--
2022-01-21 21:48:05 +03:00
=| khan-state
=* state -
|= [now=@da eny=@uvJ rof=roof]
=* khan-gate .
^?
|%
:: +call: handle a +task:khan request
::
++ call
|= $: hen=duct
dud=(unit goof)
wrapped-task=(hobo task:khan)
==
^- [(list move) _khan-gate]
::
=/ =task:khan ((harden task:khan) wrapped-task)
2022-01-26 08:28:45 +03:00
?+ -.task [~ khan-gate]
2022-01-22 01:09:01 +03:00
%born
[~ khan-gate(unix-duct hen)]
%fyrd
2022-01-26 08:28:45 +03:00
=/ wir=wire (head hen)
=/ rid=@ta (rear wir)
=* fyd p.task
2022-01-22 04:46:59 +03:00
=/ tid=@ta
(cat 3 'khan-fyrd--' rid)
=/ =beak
?@(bear.fyd [our bear.fyd %da now] [our bear.fyd])
=/ =dais:clay
?~ ret=(rof ~ %cb beak /[p.data.fyd])
~|(%mark-unknown !!)
?~ u.ret
~|(%mark-invalid !!)
?> =(%dais p.u.u.ret)
!<(dais:clay q.u.u.ret)
2022-01-26 02:37:48 +03:00
=/ args
:* ~ `tid beak name.fyd
(vale.dais q.data.fyd)
2022-01-22 04:46:59 +03:00
==
2022-01-26 02:37:48 +03:00
=/ start-moves=(list move)
%+ turn
2022-01-26 08:28:45 +03:00
:~ (watch-spider our /thread-result/[tid])
(start-spider our %spider-start !>(args))
2022-01-26 02:37:48 +03:00
==
|=(=note ^-(move [hen %pass //g note]))
2022-01-22 04:46:59 +03:00
[start-moves khan-gate]
2022-01-22 01:09:01 +03:00
==
2022-01-21 21:48:05 +03:00
:: +load: migrate an old state to a new khan version
::
++ load
|= old=khan-state
^+ khan-gate
khan-gate(state old)
2022-01-26 08:28:45 +03:00
:: +scry: nothing to see as yet
2022-01-21 21:48:05 +03:00
::
++ scry
^- roon
|= [lyc=gang car=term bem=beam]
^- (unit (unit cage))
~
++ stay state
2022-01-26 08:28:45 +03:00
:: +take: handle responses.
::
2022-01-21 21:48:05 +03:00
++ take
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _khan-gate]
?^ dud
~|(%khan-take-dud (mean tang.u.dud))
~& > [tea+tea hen+hen hin+hin]
?- -.hin
%gall
?+ -.p.hin [~ khan-gate]
?(%poke-ack %watch-ack)
?~ p.p.hin [~ khan-gate]
%- (slog u.p.p.hin)
2022-01-26 08:28:45 +03:00
:_ khan-gate
[hen %give %avow %| -.p.hin u.p.p.hin]~
::
%fact
=* cag cage.p.hin
2022-01-26 08:28:45 +03:00
?+ p.cag ~&(bad-fact+p.cag !!)
%thread-fail
2022-01-26 08:28:45 +03:00
=/ =tang !<(tang q.cag)
%- (slog tang)
:_ khan-gate
[hen %give %avow %| p.cag tang]~
::
%thread-done
:_ khan-gate
2022-01-26 08:28:45 +03:00
:: XX mark conversion
::
=/ res=* !<(* q.cag)
[hen %give %avow %& %noun res]~
==
==
::
%khan
2022-01-26 08:28:45 +03:00
:: XX unreachable?
::
!!
==
2022-01-21 21:48:05 +03:00
--