From 23d43bd5f42cff2380ffeb3e556b440473050059 Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Wed, 1 Feb 2023 17:05:18 +0100 Subject: [PATCH 1/8] Add draft code --- pkg/base-dev/lib/sss.hoon | 289 +++++++++++++++++++++++++++++++ pkg/base-dev/mar/sss/to-pub.hoon | 12 ++ pkg/base-dev/sur/sss.hoon | 37 ++++ 3 files changed, 338 insertions(+) create mode 100644 pkg/base-dev/lib/sss.hoon create mode 100644 pkg/base-dev/mar/sss/to-pub.hoon create mode 100644 pkg/base-dev/sur/sss.hoon diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon new file mode 100644 index 000000000..b4818f3d7 --- /dev/null +++ b/pkg/base-dev/lib/sss.hoon @@ -0,0 +1,289 @@ +/- *sss +:: +|% +++ mk-subs |* [=(lake) paths=mold] -:+6:(da lake paths) +++ mk-pubs |* [=(lake) paths=mold] -:+6:(du lake paths) +++ mk-mar + |* =(lake) + |_ =(response:poke lake *) + ++ grow + |% + ++ noun response + -- + ++ grab + |% + ++ noun (response:poke lake *) + -- + ++ grad %noun + -- +++ lake-mark + |= =mark + ^+ mark + ?> =('sss-' (end [3 3] mark)) + (cut 3 [4 (met 3 mark)] mark) +:: +++ fled :: Like +sped but head is a path. + |= vax=vase + ^- vase + :_ q.vax + %- ~(play ut p.vax) + =- [%wtgr [%wtts - [%& 2]~] [%$ 1]] + =/ pax ~| %need-path ;;(path -.q.vax) + |- ^- spec + ?~ pax [%base %null] + [%bccl ~[[%leaf %ta -.pax] $(pax +.pax)]] +:: +++ zoom |= =noun ~| %path-none $/sss/;;(path noun) +++ da + |* [=(lake) paths=mold] + => + |% + +$ flow + $: =aeon + rok=[=aeon fail=_| =rock:lake] + wav=((mop aeon wave:lake) lte) + == + -- + |_ [sub=(map [ship dude paths] flow) =bowl:gall result-type=type on-rock-type=type] + +* wav ((on aeon wave:lake) lte) + +$ from (on-rock:poke lake paths) + +$ into (response:poke lake paths) + +$ result (request:poke paths) + ++ pine + |= [=what =ship =dude path=paths] + ^- card:agent:gall + :* %pass (zoom request/pine/ship^dude^what^path) + %agent [ship dude] + %poke %sss-to-pub :- result-type ^- result + [path dap.bowl %pine what] + == + ++ surf + |= [=ship =dude path=paths] + (pine %wave ship dude path) + :: + ++ read + ;; (map [ship dude path] [fail=? rock:lake]) + %- ~(run by sub) + |= =flow + [fail rock]:rok.flow + :: + ++ chit + |= [[aeon=term ship=term dude=term path=paths] =sign:agent:gall] + ^+ sub + ?> ?=(%poke-ack -.sign) + ?~ p.sign sub + %+ ~(jab by sub) [(slav %p ship) dude path] + |= =flow + ?. =(aeon.rok.flow (slav %ud aeon)) flow + flow(fail.rok &) + :: + ++ behn + |= [ship=term =dude path=paths] + ^- (list card:agent:gall) + => .(ship (slav %p ship)) + ?. (~(has by sub) ship dude path) ~ + ~[(pine %wave ship dude path)] + :: + ++ apply + |= res=(response:poke lake paths) + ?~ ;;((soft path) path.res) ~| %need-path !! + ?@ payload.res + (pine-response res) + (scry-response res) + :: + ++ pine-response + |= res=[path=paths from=dude =aeon =what] + ^- (quip card:agent:gall _sub) + =* current [src.bowl from.res path.res] + =/ =flow (~(gut by sub) current *flow) + :_ (~(put by sub) current flow(aeon (max aeon.flow aeon.res))) + ?- what.res + %rock + ?. |((lth aeon.rok.flow aeon.res) =(aeon.res 0)) ~ + :~ :* %pass (zoom request/scry/(scot %p src.bowl)^from.res^what.res^(scot %ud aeon.res)^path.res) + %agent [src.bowl from.res] + %poke %sss-to-pub :- result-type ^- result + [path.res dap.bowl %scry %rock aeon.res] + == == + :: + %wave + =/ cards=(list card:agent:gall) + :~ :* %pass (zoom behn/(scot %p src.bowl)^from.res^path.res) + %arvo %b %wait (add ~s10 now.bowl) + == == + =? cards (gth aeon.res +(aeon.flow)) [(pine %rock current) cards] + =? cards (gth aeon.res aeon.rok.flow) + %+ weld cards + %+ turn (gulf +(aeon.rok.flow) aeon.res) + |= =aeon + ^- card:agent:gall + :* %pass (zoom request/scry/(scot %p src.bowl)^from.res^what.res^(scot %ud aeon)^path.res) + %agent [src.bowl from.res] + %poke %sss-to-pub :- result-type ^- result + [path.res dap.bowl %scry %wave aeon] + == + cards + == + :: + ++ scry-response + |= $: path=paths + =dude + =aeon + $%([what=%rock =rock:lake] [what=%wave =wave:lake]) + == + ^- (quip card:agent:gall _sub) + =* current [src.bowl dude path] + =/ =flow (~(gut by sub) current *flow) + ?. (lth aeon.rok.flow aeon) + %. `sub + (slog leaf/"ignoring stale {} at aeon {}" ~) + |^ + ?- what + %rock + =. wav.flow (lot:wav wav.flow `aeon ~) + =. rok.flow [aeon | rock] + =. aeon.flow (max aeon aeon.flow) + (swim ~) + :: + %wave + ?: =(aeon +(aeon.rok.flow)) + =. rok.flow [aeon | (wash:lake rock.rok.flow wave)] + (swim `wave) + `(~(put by sub) current flow(wav (put:wav wav.flow aeon wave))) + == + ++ swim + |= wave=(unit wave:lake) + ^- (quip card:agent:gall _sub) + =^ wave wav.flow (del:wav wav.flow +(aeon.rok.flow)) + ?^ wave + =. rok.flow [+(aeon.rok.flow) | (wash:lake rock.rok.flow u.wave)] + (swim wave) + :_ (~(put by sub) current flow) + :~ :* %pass (zoom on-rock/(scot %ud aeon.rok.flow)^(scot %p src.bowl)^dude^path) + %agent [our dap]:bowl + %poke %sss-on-rock :- on-rock-type ^- from + [path src.bowl dude rock.rok.flow ^wave] + == == + -- + -- +++ du + |* [=(lake) paths=mold] + => + |% + +$ rule [rocks=_1 waves=_5] + +$ tide + $: rok=((mop aeon rock:lake) gte) + wav=((mop aeon wave:lake) lte) + rul=rule + == + -- + |_ [pub=(map paths tide) =bowl:gall result-type=type] + +* rok ((on aeon rock:lake) gte) + wav ((on aeon wave:lake) lte) + :: + +$ into (request:poke paths) + +$ result (response:poke lake paths) + ++ rule + |= [path=paths =^rule] + ^+ pub + %+ ~(jab by pub) path + |= =tide + (petrify tide(rul rule)) + :: + ++ wipe + |= path=paths + ^+ pub + %+ ~(jab by pub) path + |= =tide + %* . (petrify tide(rul [0 0])) + rul rul.tide + == + ++ give + |= [path=paths =wave:lake] + ^+ pub + ?~ ;;((soft ^path) path) ~| %need-path !! + %+ ~(put by pub) path + =/ =tide (~(gut by pub) path *tide) + =/ next=aeon + .+ %+ max + (fall (bind (pry:rok rok.tide) head) 0) + (fall (bind (ram:wav wav.tide) head) 0) + =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + =. wav.tide (put:wav wav.tide next wave) + ?. =(next (add aeon.last waves.rul.tide)) tide + (petrify tide) + :: + ++ petrify + ~& %hmm + |= =tide + ^+ tide + =/ next=aeon + %+ max + (fall (bind (pry:rok rok.tide) head) 0) + (fall (bind (ram:wav wav.tide) head) 0) + =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + =. rok.tide + %+ gas:rok +<-:gas:rok + %- tab:rok :_ [~ +(rocks.rul.tide)] + %^ put:rok rok.tide next + %+ roll (tab:wav wav.tide `aeon.last waves.rul.tide) + |= [[aeon =wave:lake] =_rock.last] + (wash:lake rock wave) + ~| %rock-none + tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~)) + :: + ++ read + ;; (map path rock:lake) + %- ~(run by pub) + |= =tide + =< rock + =/ snap=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + %+ roll (tap:wav (lot:wav wav.tide `aeon.snap ~)) + |= [[=aeon =wave:lake] =_snap] + ?. =(aeon +(aeon.snap)) snap + [aeon (wash:lake rock.snap wave)] + :: + +:: %+ ~(put by pub) path +:: =/ =tide (~(gut by pub) path *tide) +:: =^ last rok.tide (pop:rok rok.tide) +:: =^ next wav.tide +:: %^ (dip:wav ,[aeon rock:lake]) +:: (lot:wav wav.tide `-.last ~) +:: last +:: |= [[aeon =rock:lake] [=aeon =wave:lake]] +:: ^- [(unit wave:lake) ? [^aeon rock:lake]] +:: [~ | aeon (wash:lake rock wave)] +:: tide(rok (put:rok +<-:put:rok next)) + :: + ++ apply + |= req=(request:poke paths) + ^- card:agent:gall + =* mark (cat 3 %sss- name:lake) + =/ =tide (~(gut by pub) path.req *tide) + ?- type.req + %scry + :* %pass (zoom response/scry/(scot %p src.bowl)^from.req^what.req^(scot %ud aeon.req)^path.req) + %agent [src.bowl from.req] + %poke mark result-type ^- result + :* path.req dap.bowl aeon.req + ?- what.req + %wave wave/(got:wav wav.tide aeon.req) + %rock ?: =(aeon.req 0) rock/*rock:lake + rock/(got:rok rok.tide aeon.req) + == == == + :: + %pine + =/ =aeon + ?- what.req + %rock key:(fall (pry:rok rok.tide) *[=key val]:rok) + %wave key:(fall (ram:wav wav.tide) *[=key val]:wav) + == + :* %pass (zoom response/pine/(scot %p src.bowl)^from.req^what.req^path.req) + %agent [src.bowl from.req] + %poke mark result-type ^- result + [path.req dap.bowl aeon what.req] + == + == + -- +-- diff --git a/pkg/base-dev/mar/sss/to-pub.hoon b/pkg/base-dev/mar/sss/to-pub.hoon new file mode 100644 index 000000000..2f57c3b1e --- /dev/null +++ b/pkg/base-dev/mar/sss/to-pub.hoon @@ -0,0 +1,12 @@ +/- *sss +|_ =(request:poke) +++ grow + |% + ++ noun request + -- +++ grab + |% + ++ noun (request:poke) + -- +++ grad %noun +-- diff --git a/pkg/base-dev/sur/sss.hoon b/pkg/base-dev/sur/sss.hoon new file mode 100644 index 000000000..9db56febb --- /dev/null +++ b/pkg/base-dev/sur/sss.hoon @@ -0,0 +1,37 @@ +|% +++ lake + |$ [rock wave] + $_ ^? + |% + ++ name *term + +$ rock ^rock + +$ wave ^wave + ++ wash |~ [rock wave] *rock + -- ++$ aeon @ud ++$ dude dude:agent:gall ++$ what ?(%rock %wave) +++ poke + |% + ++ request + |* paths=mold + $: path=paths + from=dude + $% [type=%pine =what] + [type=%scry =what aeon=@ud] + == == + ++ response + |* [=(lake) paths=mold] + $: path=paths + from=dude + aeon=@ud + $= payload + $@ =what + $% [what=%rock =rock:lake] + [what=%wave =wave:lake] + == == + ++ on-rock + |* [=(lake) paths=mold] + ,[path=paths src=ship from=dude =rock:lake wave=(unit wave:lake)] + -- +-- From 08ada13c2bf1240b4ac42f2c35ce3e6d5d8702a9 Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Wed, 1 Feb 2023 21:52:30 +0100 Subject: [PATCH 2/8] Fix snapshotting bug --- pkg/base-dev/lib/sss.hoon | 49 ++++++++++++++++----------------------- pkg/base-dev/sur/sss.hoon | 6 ++--- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index b4818f3d7..2edbd1210 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -19,7 +19,7 @@ ++ lake-mark |= =mark ^+ mark - ?> =('sss-' (end [3 3] mark)) + ?> =('sss-' (end [3 4] mark)) (cut 3 [4 (met 3 mark)] mark) :: ++ fled :: Like +sped but head is a path. @@ -188,16 +188,18 @@ ^+ pub %+ ~(jab by pub) path |= =tide - (petrify tide(rul rule)) + (form tide(rul rule)) :: ++ wipe |= path=paths ^+ pub %+ ~(jab by pub) path |= =tide - %* . (petrify tide(rul [0 0])) + %* . (form tide(rul [0 1])) rul rul.tide + wav ~ == + :: ++ give |= [path=paths =wave:lake] ^+ pub @@ -211,25 +213,27 @@ =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) =. wav.tide (put:wav wav.tide next wave) ?. =(next (add aeon.last waves.rul.tide)) tide - (petrify tide) + (form tide) :: - ++ petrify - ~& %hmm + ++ form |= =tide ^+ tide - =/ next=aeon - %+ max - (fall (bind (pry:rok rok.tide) head) 0) - (fall (bind (ram:wav wav.tide) head) 0) - =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + =/ max-rock=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + =/ max-wave (fall (bind (ram:wav wav.tide) head) 0) =. rok.tide %+ gas:rok +<-:gas:rok %- tab:rok :_ [~ +(rocks.rul.tide)] - %^ put:rok rok.tide next - %+ roll (tab:wav wav.tide `aeon.last waves.rul.tide) - |= [[aeon =wave:lake] =_rock.last] - (wash:lake rock wave) - ~| %rock-none + ?: ?| =(waves.rul.tide 0) + (lth max-wave (add aeon.max-rock waves.rul.tide)) + == + rok.tide + %+ put:rok rok.tide + %+ roll (tab:wav wav.tide `aeon.max-rock max-wave) + |: [*[now=aeon =wave:lake] `[prev=aeon =rock:lake]`max-rock] + ~| %aeon-awry + ?> =(now +(prev)) + [now (wash:lake rock wave)] + ~| %rock-zero tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~)) :: ++ read @@ -243,19 +247,6 @@ ?. =(aeon +(aeon.snap)) snap [aeon (wash:lake rock.snap wave)] :: - -:: %+ ~(put by pub) path -:: =/ =tide (~(gut by pub) path *tide) -:: =^ last rok.tide (pop:rok rok.tide) -:: =^ next wav.tide -:: %^ (dip:wav ,[aeon rock:lake]) -:: (lot:wav wav.tide `-.last ~) -:: last -:: |= [[aeon =rock:lake] [=aeon =wave:lake]] -:: ^- [(unit wave:lake) ? [^aeon rock:lake]] -:: [~ | aeon (wash:lake rock wave)] -:: tide(rok (put:rok +<-:put:rok next)) - :: ++ apply |= req=(request:poke paths) ^- card:agent:gall diff --git a/pkg/base-dev/sur/sss.hoon b/pkg/base-dev/sur/sss.hoon index 9db56febb..f6e66d158 100644 --- a/pkg/base-dev/sur/sss.hoon +++ b/pkg/base-dev/sur/sss.hoon @@ -18,13 +18,13 @@ $: path=paths from=dude $% [type=%pine =what] - [type=%scry =what aeon=@ud] + [type=%scry =what =aeon] == == ++ response |* [=(lake) paths=mold] $: path=paths - from=dude - aeon=@ud + =dude + =aeon $= payload $@ =what $% [what=%rock =rock:lake] From 34328a0ac33498f9b12a3b66160c162c913831db Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Wed, 15 Feb 2023 15:54:06 +0100 Subject: [PATCH 3/8] Ad Fontes-style networking --- pkg/base-dev/lib/mip.hoon | 55 +++++++ pkg/base-dev/lib/sss.hoon | 249 +++++++++++++++---------------- pkg/base-dev/mar/sss/to-pub.hoon | 12 -- pkg/base-dev/sur/sss.hoon | 17 +-- 4 files changed, 182 insertions(+), 151 deletions(-) create mode 100644 pkg/base-dev/lib/mip.hoon delete mode 100644 pkg/base-dev/mar/sss/to-pub.hoon diff --git a/pkg/base-dev/lib/mip.hoon b/pkg/base-dev/lib/mip.hoon new file mode 100644 index 000000000..322a4c85f --- /dev/null +++ b/pkg/base-dev/lib/mip.hoon @@ -0,0 +1,55 @@ +|% +++ mip :: map of maps + |$ [kex key value] + (map kex (map key value)) +:: +++ bi :: mip engine + =| a=(map * (map)) + |@ + ++ del + |* [b=* c=*] + =+ d=(~(gut by a) b ~) + =+ e=(~(del by d) c) + ?~ e + (~(del by a) b) + (~(put by a) b e) + :: + ++ get + |* [b=* c=*] + => .(b `_?>(?=(^ a) p.n.a)`b, c `_?>(?=(^ a) ?>(?=(^ q.n.a) p.n.q.n.a))`c) + ^- (unit _?>(?=(^ a) ?>(?=(^ q.n.a) q.n.q.n.a))) + (~(get by (~(gut by a) b ~)) c) + :: + ++ got + |* [b=* c=*] + (need (get b c)) + :: + ++ gut + |* [b=* c=* d=*] + (~(gut by (~(gut by a) b ~)) c d) + :: + ++ has + |* [b=* c=*] + !=(~ (get b c)) + :: + ++ key + |* b=* + ~(key by (~(gut by a) b ~)) + :: + ++ put + |* [b=* c=* d=*] + %+ ~(put by a) b + %. [c d] + %~ put by + (~(gut by a) b ~) + :: + ++ tap + ::NOTE naive turn-based implementation find-errors ): + =< $ + =+ b=`_?>(?=(^ a) *(list [x=_p.n.a _?>(?=(^ q.n.a) [y=p v=q]:n.q.n.a)]))`~ + |. ^+ b + ?~ a + b + $(a r.a, b (welp (turn ~(tap by q.n.a) (lead p.n.a)) $(a l.a))) + -- +-- diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index 2edbd1210..7b9e7f60e 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -1,4 +1,5 @@ /- *sss +/+ *mip :: |% ++ mk-subs |* [=(lake) paths=mold] -:+6:(da lake paths) @@ -28,44 +29,44 @@ :_ q.vax %- ~(play ut p.vax) =- [%wtgr [%wtts - [%& 2]~] [%$ 1]] - =/ pax ~| %need-path ;;(path -.q.vax) + =/ pax ~| %path-none ;;(path -.q.vax) |- ^- spec ?~ pax [%base %null] [%bccl ~[[%leaf %ta -.pax] $(pax +.pax)]] :: -++ zoom |= =noun ~| %path-none $/sss/;;(path noun) +++ zoom |= =noun ~| %need-path $/sss/;;(path noun) ++ da |* [=(lake) paths=mold] => |% - +$ flow - $: =aeon - rok=[=aeon fail=_| =rock:lake] - wav=((mop aeon wave:lake) lte) - == + +$ flow [=aeon fail=_| =rock:lake] -- |_ [sub=(map [ship dude paths] flow) =bowl:gall result-type=type on-rock-type=type] - +* wav ((on aeon wave:lake) lte) +$ from (on-rock:poke lake paths) +$ into (response:poke lake paths) +$ result (request:poke paths) - ++ pine - |= [=what =ship =dude path=paths] + ++ behn-s25 + |= [=dude =aeon path=noun] ^- card:agent:gall - :* %pass (zoom request/pine/ship^dude^what^path) - %agent [ship dude] - %poke %sss-to-pub :- result-type ^- result - [path dap.bowl %pine what] + :* %pass (zoom sub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) + %arvo %b %wait (add ~s25 now.bowl) + == + ++ pine |= [ship dude paths] (scry ~ +<) + ++ surf pine + ++ scry + |= [when=(unit aeon) who=ship which=dude where=paths] + ^- card:agent:gall + =/ when ?~ when %~ (scot %ud u.when) + :* %pass (zoom request/scry/(scot %p who)^which^when^where) + %agent [who which] + %poke %sss-to-pub :- result-type ^- result + [where which ^when] == - ++ surf - |= [=ship =dude path=paths] - (pine %wave ship dude path) - :: ++ read ;; (map [ship dude path] [fail=? rock:lake]) %- ~(run by sub) |= =flow - [fail rock]:rok.flow + [fail rock]:flow :: ++ chit |= [[aeon=term ship=term dude=term path=paths] =sign:agent:gall] @@ -74,97 +75,47 @@ ?~ p.sign sub %+ ~(jab by sub) [(slav %p ship) dude path] |= =flow - ?. =(aeon.rok.flow (slav %ud aeon)) flow - flow(fail.rok &) + ?> =(aeon.flow (slav %ud aeon)) + flow(fail &) :: ++ behn - |= [ship=term =dude path=paths] + |= [ship=term =dude aeon=term path=paths] ^- (list card:agent:gall) - => .(ship (slav %p ship)) + =/ ship (slav %p ship) ?. (~(has by sub) ship dude path) ~ - ~[(pine %wave ship dude path)] + ~[(scry `(slav %ud aeon) ship dude path)] :: ++ apply |= res=(response:poke lake paths) - ?~ ;;((soft path) path.res) ~| %need-path !! - ?@ payload.res - (pine-response res) - (scry-response res) - :: - ++ pine-response - |= res=[path=paths from=dude =aeon =what] ^- (quip card:agent:gall _sub) - =* current [src.bowl from.res path.res] - =/ =flow (~(gut by sub) current *flow) - :_ (~(put by sub) current flow(aeon (max aeon.flow aeon.res))) - ?- what.res - %rock - ?. |((lth aeon.rok.flow aeon.res) =(aeon.res 0)) ~ - :~ :* %pass (zoom request/scry/(scot %p src.bowl)^from.res^what.res^(scot %ud aeon.res)^path.res) - %agent [src.bowl from.res] - %poke %sss-to-pub :- result-type ^- result - [path.res dap.bowl %scry %rock aeon.res] - == == + ?- type.res + %yore + :_ sub :_ ~ + (pine src.bowl dude.res path.res) :: - %wave - =/ cards=(list card:agent:gall) - :~ :* %pass (zoom behn/(scot %p src.bowl)^from.res^path.res) - %arvo %b %wait (add ~s10 now.bowl) - == == - =? cards (gth aeon.res +(aeon.flow)) [(pine %rock current) cards] - =? cards (gth aeon.res aeon.rok.flow) - %+ weld cards - %+ turn (gulf +(aeon.rok.flow) aeon.res) - |= =aeon - ^- card:agent:gall - :* %pass (zoom request/scry/(scot %p src.bowl)^from.res^what.res^(scot %ud aeon)^path.res) - %agent [src.bowl from.res] - %poke %sss-to-pub :- result-type ^- result - [path.res dap.bowl %scry %wave aeon] - == - cards - == - :: - ++ scry-response - |= $: path=paths - =dude - =aeon - $%([what=%rock =rock:lake] [what=%wave =wave:lake]) - == - ^- (quip card:agent:gall _sub) - =* current [src.bowl dude path] - =/ =flow (~(gut by sub) current *flow) - ?. (lth aeon.rok.flow aeon) - %. `sub - (slog leaf/"ignoring stale {} at aeon {}" ~) - |^ - ?- what - %rock - =. wav.flow (lot:wav wav.flow `aeon ~) - =. rok.flow [aeon | rock] - =. aeon.flow (max aeon aeon.flow) - (swim ~) + %nigh + :_ sub :_ ~ + (behn-s25 [dude aeon path]:res) :: - %wave - ?: =(aeon +(aeon.rok.flow)) - =. rok.flow [aeon | (wash:lake rock.rok.flow wave)] - (swim `wave) - `(~(put by sub) current flow(wav (put:wav wav.flow aeon wave))) - == - ++ swim - |= wave=(unit wave:lake) - ^- (quip card:agent:gall _sub) - =^ wave wav.flow (del:wav wav.flow +(aeon.rok.flow)) - ?^ wave - =. rok.flow [+(aeon.rok.flow) | (wash:lake rock.rok.flow u.wave)] - (swim wave) + %scry + =* current [src.bowl dude.res path.res] + =/ [wave=(unit wave:lake) =flow] + =/ old=flow (~(gut by sub) current *flow) + ?- what.res + %rock ?> (gte aeon.res aeon.old) + `[aeon.res | rock.res] + %wave ?> =(aeon.res +(aeon.old)) + [`wave.res [aeon.res | (wash:lake rock.old wave.res)]] + == :_ (~(put by sub) current flow) - :~ :* %pass (zoom on-rock/(scot %ud aeon.rok.flow)^(scot %p src.bowl)^dude^path) + %- flop + :~ (scry `+(aeon.res) src.bowl dude.res path.res) + :* %pass (zoom on-rock/(scot %ud aeon.flow)^(scot %p src.bowl)^dude.res^path.res) %agent [our dap]:bowl - %poke %sss-on-rock :- on-rock-type ^- from - [path src.bowl dude rock.rok.flow ^wave] + %poke %sss-on-rock on-rock-type ^- from + [path.res src.bowl dude.res rock.flow wave] == == - -- + == -- ++ du |* [=(lake) paths=mold] @@ -175,6 +126,7 @@ $: rok=((mop aeon rock:lake) gte) wav=((mop aeon wave:lake) lte) rul=rule + mem=(mip aeon [ship dude] @da) == -- |_ [pub=(map paths tide) =bowl:gall result-type=type] @@ -183,6 +135,18 @@ :: +$ into (request:poke paths) +$ result (response:poke lake paths) + ++ behn-s25 + |= [=dude =aeon path=noun] + ^- card:agent:gall + :* %pass (zoom pub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) + %arvo %b %wait (add ~s25 now.bowl) + == + ++ behn-rest + |= [=ship =dude =aeon path=noun =@da] + ^- card:agent:gall + :* %pass (zoom pub/behn/(scot %p ship)^dude^(scot %ud aeon)^path) + %arvo %b %rest da + == ++ rule |= [path=paths =^rule] ^+ pub @@ -199,22 +163,46 @@ rul rul.tide wav ~ == + ++ behn + |= [ship=term =dude aeon=term path=paths] + ^+ pub + %+ ~(jab by pub) path + |= =tide + ^+ tide + tide(mem (~(del bi mem.tide) (slav %ud aeon) (slav %p ship) dude)) :: + ++ send + |= [=wave:lake =ship =dude =aeon path=paths] + ^- card:agent:gall + =* mark (cat 3 %sss- name:lake) + :* %pass (zoom response/scry/(scot %p ship)^dude^(scot %ud aeon)^path) + %agent [ship dude] + %poke mark result-type ^- (response:poke lake paths) + [path dap.bowl aeon scry/wave/wave] + == ++ give |= [path=paths =wave:lake] - ^+ pub + ^- (quip card:agent:gall _pub) ?~ ;;((soft ^path) path) ~| %need-path !! - %+ ~(put by pub) path =/ =tide (~(gut by pub) path *tide) =/ next=aeon - .+ %+ max + .+ %+ max (fall (bind (pry:rok rok.tide) head) 0) (fall (bind (ram:wav wav.tide) head) 0) - =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) - =. wav.tide (put:wav wav.tide next wave) - ?. =(next (add aeon.last waves.rul.tide)) tide - (form tide) - :: + :: + :_ %+ ~(put by pub) path + =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + =. wav.tide (put:wav wav.tide next wave) + =. mem.tide (~(del by mem.tide) next) + ?. =(next (add aeon.last waves.rul.tide)) tide + (form tide) + :: + %+ (corl zing turn) ~(tap by (~(gut by mem.tide) next ~)) + |= [[=ship =dude] =@da] + ^- (list card:agent:gall) + :~ (behn-rest ship dude next path da) + (send wave ship dude next path) + == ++ form |= =tide ^+ tide @@ -249,32 +237,33 @@ :: ++ apply |= req=(request:poke paths) - ^- card:agent:gall - =* mark (cat 3 %sss- name:lake) + |^ ^- (quip card:agent:gall _pub) =/ =tide (~(gut by pub) path.req *tide) - ?- type.req - %scry - :* %pass (zoom response/scry/(scot %p src.bowl)^from.req^what.req^(scot %ud aeon.req)^path.req) - %agent [src.bowl from.req] - %poke mark result-type ^- result - :* path.req dap.bowl aeon.req - ?- what.req - %wave wave/(got:wav wav.tide aeon.req) - %rock ?: =(aeon.req 0) rock/*rock:lake - rock/(got:rok rok.tide aeon.req) - == == == - :: - %pine - =/ =aeon - ?- what.req - %rock key:(fall (pry:rok rok.tide) *[=key val]:rok) - %wave key:(fall (ram:wav wav.tide) *[=key val]:wav) - == - :* %pass (zoom response/pine/(scot %p src.bowl)^from.req^what.req^path.req) - %agent [src.bowl from.req] - %poke mark result-type ^- result - [path.req dap.bowl aeon what.req] - == + ?~ when.req + =/ last (fall (pry:rok rok.tide) *[=key =val]:rok) + :_ pub :_ ~ + (mk-card key.last scry/rock/val.last) + ?^ dat=(get:wav wav.tide u.when.req) + :_ pub :_ ~ + (mk-card u.when.req scry/wave/u.dat) + ?. (gth u.when.req key::(fall (ram:wav wav.tide) [key=+(u.when.req) **])) + :_ pub :_ ~ + (mk-card u.when.req yore/~) + :- ~[(behn-s25 [dude u.when path]:req) (mk-card u.when.req nigh/~)] + %+ ~(put by pub) path.req + %= tide mem + %^ ~(put bi mem.tide) u.when.req [src.bowl dude.req] + (add ~s25 now.bowl) == + :: + ++ mk-card + |= dat=_|2:*(response:poke lake paths) + =* mark (cat 3 %sss- name:lake) + =* when ?~(when.req %$ (scot %ud u.when.req)) + :* %pass (zoom response/scry/(scot %p src.bowl)^dude.req^when^path.req) + %agent [src.bowl dude.req] + %poke mark result-type path.req dap.bowl dat + == + -- -- -- diff --git a/pkg/base-dev/mar/sss/to-pub.hoon b/pkg/base-dev/mar/sss/to-pub.hoon deleted file mode 100644 index 2f57c3b1e..000000000 --- a/pkg/base-dev/mar/sss/to-pub.hoon +++ /dev/null @@ -1,12 +0,0 @@ -/- *sss -|_ =(request:poke) -++ grow - |% - ++ noun request - -- -++ grab - |% - ++ noun (request:poke) - -- -++ grad %noun --- diff --git a/pkg/base-dev/sur/sss.hoon b/pkg/base-dev/sur/sss.hoon index f6e66d158..9533719d7 100644 --- a/pkg/base-dev/sur/sss.hoon +++ b/pkg/base-dev/sur/sss.hoon @@ -16,20 +16,19 @@ ++ request |* paths=mold $: path=paths - from=dude - $% [type=%pine =what] - [type=%scry =what =aeon] - == == + =dude + when=(unit aeon) + == ++ response |* [=(lake) paths=mold] $: path=paths =dude =aeon - $= payload - $@ =what - $% [what=%rock =rock:lake] - [what=%wave =wave:lake] - == == + $% [type=?(%nigh %yore) ~] + $: type=%scry + $% [what=%rock =rock:lake] + [what=%wave =wave:lake] + == == == == ++ on-rock |* [=(lake) paths=mold] ,[path=paths src=ship from=dude =rock:lake wave=(unit wave:lake)] From 55c3fedcfa8e9ec5750417e4761afe9d03b3b224 Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Thu, 16 Feb 2023 07:46:52 +0100 Subject: [PATCH 4/8] Use `^-` instead of `;;` because to save resources (and cleaner) --- pkg/base-dev/lib/sss.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index 7b9e7f60e..cf12e2aba 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -63,7 +63,7 @@ [where which ^when] == ++ read - ;; (map [ship dude path] [fail=? rock:lake]) + ^- (map [ship dude paths] [fail=? rock:lake]) %- ~(run by sub) |= =flow [fail rock]:flow @@ -225,7 +225,7 @@ tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~)) :: ++ read - ;; (map path rock:lake) + ^- (map paths rock:lake) %- ~(run by pub) |= =tide =< rock From 6f31ad889a9180fd8c6498b36c9fa7a3cf507765 Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Thu, 16 Feb 2023 08:58:15 +0100 Subject: [PATCH 5/8] `%rest` stale timers on subscriber --- pkg/base-dev/lib/sss.hoon | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index cf12e2aba..abc9d839a 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -82,8 +82,10 @@ |= [ship=term =dude aeon=term path=paths] ^- (list card:agent:gall) =/ ship (slav %p ship) - ?. (~(has by sub) ship dude path) ~ - ~[(scry `(slav %ud aeon) ship dude path)] + ?~ flow=(~(get by sub) ship dude path) ~ + =/ aeon (slav %ud aeon) + ?: (gte aeon.u.flow aeon) ~ + ~[(scry `aeon ship dude path)] :: ++ apply |= res=(response:poke lake paths) @@ -104,7 +106,8 @@ ?- what.res %rock ?> (gte aeon.res aeon.old) `[aeon.res | rock.res] - %wave ?> =(aeon.res +(aeon.old)) + %wave ~| [%weird-wave res=res old=old] + ?> =(aeon.res +(aeon.old)) [`wave.res [aeon.res | (wash:lake rock.old wave.res)]] == :_ (~(put by sub) current flow) @@ -172,13 +175,13 @@ tide(mem (~(del bi mem.tide) (slav %ud aeon) (slav %p ship) dude)) :: ++ send - |= [=wave:lake =ship =dude =aeon path=paths] + |= [payload=_|3:*(response:poke lake paths) =ship =dude =aeon path=paths] ^- card:agent:gall =* mark (cat 3 %sss- name:lake) :* %pass (zoom response/scry/(scot %p ship)^dude^(scot %ud aeon)^path) %agent [ship dude] %poke mark result-type ^- (response:poke lake paths) - [path dap.bowl aeon scry/wave/wave] + [path dap.bowl aeon payload] == ++ give |= [path=paths =wave:lake] @@ -201,7 +204,7 @@ |= [[=ship =dude] =@da] ^- (list card:agent:gall) :~ (behn-rest ship dude next path da) - (send wave ship dude next path) + (send scry/wave/wave ship dude next path) == ++ form |= =tide @@ -237,33 +240,25 @@ :: ++ apply |= req=(request:poke paths) - |^ ^- (quip card:agent:gall _pub) + ^- (quip card:agent:gall _pub) =/ =tide (~(gut by pub) path.req *tide) ?~ when.req =/ last (fall (pry:rok rok.tide) *[=key =val]:rok) :_ pub :_ ~ - (mk-card key.last scry/rock/val.last) + (send scry/rock/val.last src.bowl dude.req key.last path.req) ?^ dat=(get:wav wav.tide u.when.req) :_ pub :_ ~ - (mk-card u.when.req scry/wave/u.dat) + (send scry/wave/u.dat src.bowl [dude u.when path]:req) ?. (gth u.when.req key::(fall (ram:wav wav.tide) [key=+(u.when.req) **])) :_ pub :_ ~ - (mk-card u.when.req yore/~) - :- ~[(behn-s25 [dude u.when path]:req) (mk-card u.when.req nigh/~)] + (send yore/~ src.bowl [dude u.when path]:req) + :- :~ (behn-s25 [dude u.when path]:req) + (send nigh/~ src.bowl [dude u.when path]:req) + == %+ ~(put by pub) path.req %= tide mem %^ ~(put bi mem.tide) u.when.req [src.bowl dude.req] (add ~s25 now.bowl) == - :: - ++ mk-card - |= dat=_|2:*(response:poke lake paths) - =* mark (cat 3 %sss- name:lake) - =* when ?~(when.req %$ (scot %ud u.when.req)) - :* %pass (zoom response/scry/(scot %p src.bowl)^dude.req^when^path.req) - %agent [src.bowl dude.req] - %poke mark result-type path.req dap.bowl dat - == - -- -- -- From 6055266d85d08c2b1f87f47d85aa8cf1ff4050de Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Thu, 16 Feb 2023 14:49:25 +0100 Subject: [PATCH 6/8] Comment `/lib/sss/hoon` --- pkg/base-dev/lib/sss.hoon | 186 ++++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 88 deletions(-) diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index abc9d839a..44b438b1e 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -2,9 +2,15 @@ /+ *mip :: |% -++ mk-subs |* [=(lake) paths=mold] -:+6:(da lake paths) -++ mk-pubs |* [=(lake) paths=mold] -:+6:(du lake paths) -++ mk-mar +++ mk-subs :: Create sub-map. + |* [=(lake) paths=mold] + -:+6:(da lake paths) +:: +++ mk-pubs :: Create pub-map. + |* [=(lake) paths=mold] + -:+6:(du lake paths) +:: +++ mk-mar :: Create mar. |* =(lake) |_ =(response:poke lake *) ++ grow @@ -17,12 +23,6 @@ -- ++ grad %noun -- -++ lake-mark - |= =mark - ^+ mark - ?> =('sss-' (end [3 4] mark)) - (cut 3 [4 (met 3 mark)] mark) -:: ++ fled :: Like +sped but head is a path. |= vax=vase ^- vase @@ -35,40 +35,23 @@ [%bccl ~[[%leaf %ta -.pax] $(pax +.pax)]] :: ++ zoom |= =noun ~| %need-path $/sss/;;(path noun) -++ da +:: +++ da :: Manage subscriptions. |* [=(lake) paths=mold] => |% +$ flow [=aeon fail=_| =rock:lake] -- |_ [sub=(map [ship dude paths] flow) =bowl:gall result-type=type on-rock-type=type] - +$ from (on-rock:poke lake paths) - +$ into (response:poke lake paths) - +$ result (request:poke paths) - ++ behn-s25 - |= [=dude =aeon path=noun] - ^- card:agent:gall - :* %pass (zoom sub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) - %arvo %b %wait (add ~s25 now.bowl) - == - ++ pine |= [ship dude paths] (scry ~ +<) - ++ surf pine - ++ scry - |= [when=(unit aeon) who=ship which=dude where=paths] - ^- card:agent:gall - =/ when ?~ when %~ (scot %ud u.when) - :* %pass (zoom request/scry/(scot %p who)^which^when^where) - %agent [who which] - %poke %sss-to-pub :- result-type ^- result - [where which ^when] - == - ++ read + ++ surf pine :: Subscribe to [ship dude path]. + ++ read :: See current subscribed states. ^- (map [ship dude paths] [fail=? rock:lake]) %- ~(run by sub) |= =flow [fail rock]:flow - :: - ++ chit + :: :: Check poke-acks for errors. + :: :: If an %sss-on-rock poke nacks, + ++ chit :: that state is flagged as failed. |= [[aeon=term ship=term dude=term path=paths] =sign:agent:gall] ^+ sub ?> ?=(%poke-ack -.sign) @@ -77,8 +60,10 @@ |= =flow ?> =(aeon.flow (slav %ud aeon)) flow(fail &) - :: - ++ behn + :: :: Check if we're still interested + :: :: in a wave. If no, no-op. + :: :: If yes, scry. + ++ behn :: (See https://gist.github.com/belisarius222/7f8452bfea9b199c0ed717ab1778f35b) |= [ship=term =dude aeon=term path=paths] ^- (list card:agent:gall) =/ ship (slav %p ship) @@ -87,7 +72,7 @@ ?: (gte aeon.u.flow aeon) ~ ~[(scry `aeon ship dude path)] :: - ++ apply + ++ apply :: Handle response from publisher. |= res=(response:poke lake paths) ^- (quip card:agent:gall _sub) ?- type.res @@ -119,12 +104,34 @@ [path.res src.bowl dude.res rock.flow wave] == == == + :: + :: Non-public facing arms below + :: + +$ from (on-rock:poke lake paths) + +$ into (response:poke lake paths) + +$ result (request:poke paths) + ++ behn-s25 + |= [=dude =aeon path=noun] + ^- card:agent:gall + :* %pass (zoom sub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) + %arvo %b %wait (add ~s25 now.bowl) + == + ++ pine |= [ship dude paths] (scry ~ +<) + ++ scry + |= [when=(unit aeon) who=ship which=dude where=paths] + ^- card:agent:gall + =/ when ?~ when %~ (scot %ud u.when) + :* %pass (zoom request/scry/(scot %p who)^which^when^where) + %agent [who which] + %poke %sss-to-pub :- result-type ^- result + [where which ^when] + == -- -++ du +++ du :: Manage publications. |* [=(lake) paths=mold] => |% - +$ rule [rocks=_1 waves=_5] + +$ rule [rocks=_1 waves=_5] :: Retention policy +$ tide $: rok=((mop aeon rock:lake) gte) wav=((mop aeon wave:lake) lte) @@ -136,28 +143,14 @@ +* rok ((on aeon rock:lake) gte) wav ((on aeon wave:lake) lte) :: - +$ into (request:poke paths) - +$ result (response:poke lake paths) - ++ behn-s25 - |= [=dude =aeon path=noun] - ^- card:agent:gall - :* %pass (zoom pub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) - %arvo %b %wait (add ~s25 now.bowl) - == - ++ behn-rest - |= [=ship =dude =aeon path=noun =@da] - ^- card:agent:gall - :* %pass (zoom pub/behn/(scot %p ship)^dude^(scot %ud aeon)^path) - %arvo %b %rest da - == - ++ rule + ++ rule :: Set new retention policy. |= [path=paths =^rule] ^+ pub %+ ~(jab by pub) path |= =tide (form tide(rul rule)) :: - ++ wipe + ++ wipe :: Create new rock and wipe rest. |= path=paths ^+ pub %+ ~(jab by pub) path @@ -166,7 +159,8 @@ rul rul.tide wav ~ == - ++ behn + :: :: Remove sticky scry request. + ++ behn :: (See https://gist.github.com/belisarius222/7f8452bfea9b199c0ed717ab1778f35b) |= [ship=term =dude aeon=term path=paths] ^+ pub %+ ~(jab by pub) path @@ -174,16 +168,7 @@ ^+ tide tide(mem (~(del bi mem.tide) (slav %ud aeon) (slav %p ship) dude)) :: - ++ send - |= [payload=_|3:*(response:poke lake paths) =ship =dude =aeon path=paths] - ^- card:agent:gall - =* mark (cat 3 %sss- name:lake) - :* %pass (zoom response/scry/(scot %p ship)^dude^(scot %ud aeon)^path) - %agent [ship dude] - %poke mark result-type ^- (response:poke lake paths) - [path dap.bowl aeon payload] - == - ++ give + ++ give :: Give a wave on a path. |= [path=paths =wave:lake] ^- (quip card:agent:gall _pub) ?~ ;;((soft ^path) path) ~| %need-path !! @@ -206,28 +191,7 @@ :~ (behn-rest ship dude next path da) (send scry/wave/wave ship dude next path) == - ++ form - |= =tide - ^+ tide - =/ max-rock=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) - =/ max-wave (fall (bind (ram:wav wav.tide) head) 0) - =. rok.tide - %+ gas:rok +<-:gas:rok - %- tab:rok :_ [~ +(rocks.rul.tide)] - ?: ?| =(waves.rul.tide 0) - (lth max-wave (add aeon.max-rock waves.rul.tide)) - == - rok.tide - %+ put:rok rok.tide - %+ roll (tab:wav wav.tide `aeon.max-rock max-wave) - |: [*[now=aeon =wave:lake] `[prev=aeon =rock:lake]`max-rock] - ~| %aeon-awry - ?> =(now +(prev)) - [now (wash:lake rock wave)] - ~| %rock-zero - tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~)) - :: - ++ read + ++ read :: See current published states. ^- (map paths rock:lake) %- ~(run by pub) |= =tide @@ -238,7 +202,7 @@ ?. =(aeon +(aeon.snap)) snap [aeon (wash:lake rock.snap wave)] :: - ++ apply + ++ apply :: Handle request from subscriber. |= req=(request:poke paths) ^- (quip card:agent:gall _pub) =/ =tide (~(gut by pub) path.req *tide) @@ -260,5 +224,51 @@ %^ ~(put bi mem.tide) u.when.req [src.bowl dude.req] (add ~s25 now.bowl) == + :: + :: Non-public facing arms below + :: + +$ into (request:poke paths) + +$ result (response:poke lake paths) + ++ behn-s25 + |= [=dude =aeon path=noun] + ^- card:agent:gall + :* %pass (zoom pub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) + %arvo %b %wait (add ~s25 now.bowl) + == + ++ behn-rest + |= [=ship =dude =aeon path=noun =@da] + ^- card:agent:gall + :* %pass (zoom pub/behn/(scot %p ship)^dude^(scot %ud aeon)^path) + %arvo %b %rest da + == + ++ send + |= [payload=_|3:*(response:poke lake paths) =ship =dude =aeon path=paths] + ^- card:agent:gall + =* mark (cat 3 %sss- name:lake) + :* %pass (zoom response/scry/(scot %p ship)^dude^(scot %ud aeon)^path) + %agent [ship dude] + %poke mark result-type ^- (response:poke lake paths) + [path dap.bowl aeon payload] + == + ++ form + |= =tide + ^+ tide + =/ max-rock=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok) + =/ max-wave (fall (bind (ram:wav wav.tide) head) 0) + =. rok.tide + %+ gas:rok +<-:gas:rok + %- tab:rok :_ [~ +(rocks.rul.tide)] + ?: ?| =(waves.rul.tide 0) + (lth max-wave (add aeon.max-rock waves.rul.tide)) + == + rok.tide + %+ put:rok rok.tide + %+ roll (tab:wav wav.tide `aeon.max-rock max-wave) + |: [*[now=aeon =wave:lake] `[prev=aeon =rock:lake]`max-rock] + ~| %aeon-awry + ?> =(now +(prev)) + [now (wash:lake rock wave)] + ~| %rock-zero + tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~)) -- -- From 26c7a94321407e253e7bcb2510f51a671ebcef9f Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Thu, 16 Feb 2023 14:57:47 +0100 Subject: [PATCH 7/8] Crash if we're woken up for a subscription we don't have --- pkg/base-dev/lib/sss.hoon | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index 44b438b1e..e8f8cd339 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -67,9 +67,8 @@ |= [ship=term =dude aeon=term path=paths] ^- (list card:agent:gall) =/ ship (slav %p ship) - ?~ flow=(~(get by sub) ship dude path) ~ =/ aeon (slav %ud aeon) - ?: (gte aeon.u.flow aeon) ~ + ?: (lte aeon aeon:(~(got by sub) ship dude path)) ~ ~[(scry `aeon ship dude path)] :: ++ apply :: Handle response from publisher. From 7e4f7d4bc63919b7c66a335ceba7783b1eb07967 Mon Sep 17 00:00:00 2001 From: ~wicrum-wicrun <99811688+wicrum-wicrun@users.noreply.github.com> Date: Fri, 17 Feb 2023 10:22:58 +0100 Subject: [PATCH 8/8] Publisher doesn't set timer --- pkg/base-dev/lib/sss.hoon | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/pkg/base-dev/lib/sss.hoon b/pkg/base-dev/lib/sss.hoon index e8f8cd339..a1a4a4b24 100644 --- a/pkg/base-dev/lib/sss.hoon +++ b/pkg/base-dev/lib/sss.hoon @@ -112,7 +112,7 @@ ++ behn-s25 |= [=dude =aeon path=noun] ^- card:agent:gall - :* %pass (zoom sub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) + :* %pass (zoom behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) %arvo %b %wait (add ~s25 now.bowl) == ++ pine |= [ship dude paths] (scry ~ +<) @@ -158,15 +158,6 @@ rul rul.tide wav ~ == - :: :: Remove sticky scry request. - ++ behn :: (See https://gist.github.com/belisarius222/7f8452bfea9b199c0ed717ab1778f35b) - |= [ship=term =dude aeon=term path=paths] - ^+ pub - %+ ~(jab by pub) path - |= =tide - ^+ tide - tide(mem (~(del bi mem.tide) (slav %ud aeon) (slav %p ship) dude)) - :: ++ give :: Give a wave on a path. |= [path=paths =wave:lake] ^- (quip card:agent:gall _pub) @@ -184,12 +175,10 @@ ?. =(next (add aeon.last waves.rul.tide)) tide (form tide) :: - %+ (corl zing turn) ~(tap by (~(gut by mem.tide) next ~)) + %+ murn ~(tap by (~(gut by mem.tide) next ~)) |= [[=ship =dude] =@da] - ^- (list card:agent:gall) - :~ (behn-rest ship dude next path da) - (send scry/wave/wave ship dude next path) - == + ?: (lth da now.bowl) ~ + `(send scry/wave/wave ship dude next path) ++ read :: See current published states. ^- (map paths rock:lake) %- ~(run by pub) @@ -215,9 +204,7 @@ ?. (gth u.when.req key::(fall (ram:wav wav.tide) [key=+(u.when.req) **])) :_ pub :_ ~ (send yore/~ src.bowl [dude u.when path]:req) - :- :~ (behn-s25 [dude u.when path]:req) - (send nigh/~ src.bowl [dude u.when path]:req) - == + :- ~[(send nigh/~ src.bowl [dude u.when path]:req)] %+ ~(put by pub) path.req %= tide mem %^ ~(put bi mem.tide) u.when.req [src.bowl dude.req] @@ -228,18 +215,6 @@ :: +$ into (request:poke paths) +$ result (response:poke lake paths) - ++ behn-s25 - |= [=dude =aeon path=noun] - ^- card:agent:gall - :* %pass (zoom pub/behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path) - %arvo %b %wait (add ~s25 now.bowl) - == - ++ behn-rest - |= [=ship =dude =aeon path=noun =@da] - ^- card:agent:gall - :* %pass (zoom pub/behn/(scot %p ship)^dude^(scot %ud aeon)^path) - %arvo %b %rest da - == ++ send |= [payload=_|3:*(response:poke lake paths) =ship =dude =aeon path=paths] ^- card:agent:gall