From 8ad57d8bd220e8474a0795bd90550404cb44c144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Tue, 25 Jan 2022 21:28:45 -0800 Subject: [PATCH] khan: cleanup --- pkg/arvo/sys/lull.hoon | 4 +-- pkg/arvo/sys/vane/khan.hoon | 54 +++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/pkg/arvo/sys/lull.hoon b/pkg/arvo/sys/lull.hoon index 6c321ccf2c..cfb4d549da 100644 --- a/pkg/arvo/sys/lull.hoon +++ b/pkg/arvo/sys/lull.hoon @@ -2098,13 +2098,13 @@ ++ khan ^? |% +$ gift :: out result <-$ - $% [%avow p=(each cage [term tang])] :: thread result + $% [%avow p=(each [mark noun] [term tang])] :: thread result == +$ task :: in request ->$ $~ [%vega ~] $% $>(%born vane-task) :: new unix process [%done ~] :: socket closed - [%fyrd =beak name=term data=*] :: run thread v0 + [%fyrd =desk name=term data=*] :: run thread v0 $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade == diff --git a/pkg/arvo/sys/vane/khan.hoon b/pkg/arvo/sys/vane/khan.hoon index b39875abae..597bc3729b 100644 --- a/pkg/arvo/sys/vane/khan.hoon +++ b/pkg/arvo/sys/vane/khan.hoon @@ -49,27 +49,33 @@ ^- [(list move) _khan-gate] :: =/ =task:khan ((harden task:khan) wrapped-task) - ?- -.task - %vega - [~ khan-gate] - %trim - [~ khan-gate] - %done - [~ khan-gate] + ?+ -.task [~ khan-gate] %born [~ khan-gate(unix-duct hen)] %fyrd - =/ rid=@ta (rear (head hen)) + :: start the thread on %spider. + :: + =/ wir=wire (head hen) + =/ rid=@ta (rear wir) + :: XX what if the client sends a duplicate rid? + :: is this fine? should we inject some randomness? + :: =/ tid=@ta (cat 3 'khan-fyrd--' rid) =/ args - :* ~ `tid [our q.beak.task %da now] name.task - !>([~ ~zod]) + :* ~ `tid [our desk.task %da now] name.task + :: XX can't do this: + :: + :: !>(data.task) + :: + :: special case for -hi: + :: + !>(;;([~ arg=$@(who=ship [who=ship mez=tape])] data.task)) == =/ start-moves=(list move) %+ turn - :~ (watch-spider p.beak.task /thread-result/[tid]) - (start-spider p.beak.task %spider-start !>(args)) + :~ (watch-spider our /thread-result/[tid]) + (start-spider our %spider-start !>(args)) == |=(=note ^-(move [hen %pass //g note])) [start-moves khan-gate] @@ -80,7 +86,7 @@ |= old=khan-state ^+ khan-gate khan-gate(state old) -:: +scry: view khan state +:: +scry: nothing to see as yet :: ++ scry ^- roon @@ -88,6 +94,8 @@ ^- (unit (unit cage)) ~ ++ stay state +:: +take: handle responses. +:: ++ take |= [tea=wire hen=duct dud=(unit goof) hin=sign] ^- [(list move) _khan-gate] @@ -100,24 +108,30 @@ ?(%poke-ack %watch-ack) ?~ p.p.hin [~ khan-gate] %- (slog u.p.p.hin) - [~ khan-gate] + :_ khan-gate + [hen %give %avow %| -.p.hin u.p.p.hin]~ :: %fact =* cag cage.p.hin - ?+ p.cag !! + ?+ p.cag ~&(bad-fact+p.cag !!) %thread-fail - %- (slog !<(tang q.cag)) - [~ khan-gate] + =/ =tang !<(tang q.cag) + %- (slog tang) + :_ khan-gate + [hen %give %avow %| p.cag tang]~ :: %thread-done :_ khan-gate - =/ mov=move - [hen %give %avow %& %tape !>(~)] - ~[mov] + :: XX mark conversion + :: + =/ res=* !<(* q.cag) + [hen %give %avow %& %noun res]~ == == :: %khan + :: XX unreachable? + :: !! == --