From a08c38b83cb1adecc84e4cf5444943bdb7419be8 Mon Sep 17 00:00:00 2001 From: ryjm Date: Sat, 25 Sep 2021 02:50:21 -0400 Subject: [PATCH] spider: track desks and validate marks (wip) --- pkg/arvo/app/spider.hoon | 45 ++++++++++++++++++++++-------------- pkg/base-dev/lib/strand.hoon | 23 +++++++++++++++++- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/app/spider.hoon b/pkg/arvo/app/spider.hoon index 0bc957b20..f95faf1c9 100644 --- a/pkg/arvo/app/spider.hoon +++ b/pkg/arvo/app/spider.hoon @@ -18,7 +18,7 @@ $: starting=(map yarn [=trying =vase]) running=trie tid=(map tid yarn) - serving=(map tid [@ta =mark =desk]) + serving=(map tid [(unit @ta) =mark =desk]) == :: +$ clean-slate-any @@ -318,14 +318,10 @@ =* output-mark i.t.t.t.t.site.url =/ =tid (new-thread-id thread) =. serving.state - (~(put by serving.state) tid [eyre-id output-mark desk]) + (~(put by serving.state) tid [`eyre-id output-mark desk]) :: TODO: speed this up somehow. we spend about 15ms in this arm alone :: - =+ .^ - =tube:clay - %cc - /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/json/[input-mark] - == + =/ tube (convert-tube %json input-mark desk bowl) ?> ?=(^ body.request.inbound-request) =/ body=json (need (de-json:html q.u.body.request.inbound-request)) =/ input=vase (slop !>(~) (tube !>(body))) @@ -543,15 +539,11 @@ =- (fall - `state) %+ bind (~(get by serving.state) tid) - |= [eyre-id=@ta output=mark =desk] - =+ .^ - =tube:clay - %cc - /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[output]/json - == - :_ state(serving (~(del by serving.state) tid)) - %+ give-simple-payload:app:server eyre-id - (json-response:gen:server !<(json (tube vase))) + |= [eyre-id=(unit @ta) output=mark =desk] + =/ tube (convert-tube output %json desk bowl) + :_ state(serving (~(del by serving.state) tid) + %+ give-simple-payload:app:server (need eyre-id) + (json-response:gen:server !<(%json (tube vase)) :: ++ thread-done |= [=yarn =vase] @@ -604,7 +596,7 @@ sup.bowl eny.bowl now.bowl - byk.bowl + (yarn-to-byk yarn bowl) == :: ++ yarn-to-tid @@ -623,7 +615,26 @@ ~ `i.t.nary :: +++ yarn-to-byk + |= [=yarn =bowl] + ^- beak + =/ tid (yarn-to-tid yarn) + %+ bind + (~(get by serving.state) tid) + |= [* * =desk] + =/ boc bec + boc(q desk) +:: ++ clean-state !> ^- clean-slate 3+state(running (turn (tap-yarn running.state) head)) +:: +++ convert-tube + |= [from=mark to=mark =desk =bowl] + .^ + tube:clay + %cc + /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[from]/[to] + == + -- diff --git a/pkg/base-dev/lib/strand.hoon b/pkg/base-dev/lib/strand.hoon index b618f2d4e..ab54f15fb 100644 --- a/pkg/base-dev/lib/strand.hoon +++ b/pkg/base-dev/lib/strand.hoon @@ -128,6 +128,19 @@ [%done value=a] == :: + ++ validate-mark + |= [in=* =mark =desk =bowl] + =+ .^ + sky=* + %cb + /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[mark] + == + =+ !<(=dais:clay q.u.u.sky) + =/ res (mule |.((vale:dais in))) + ?: ?=(%| -.res) + (mean leaf+"gall: ames vale fail {}" p.res) + p.res + :: :: Take a new sign and run the strand against it :: ++ take @@ -137,9 +150,16 @@ |= [=eval-form =strand-input] ^- [[(list card) =eval-result] _eval-form] =* take-loop $ + =/ validated-input=^strand-input + =. in.strand-input + %+ bind + in.strand-input + |= in=input:strand + ?. ?=(%sign -.in) in + `(validate-mark q.cage.sign.in p.cage.sign.in q.byk.bowl.strand-input) :: run the strand callback :: - =/ =output (form.eval-form strand-input) + =/ =output (form.eval-form validated-input) :: add cards to cards :: =. cards @@ -165,3 +185,4 @@ -- -- -- +::