shrub/pkg/arvo/app/hood.hoon

107 lines
2.9 KiB
Plaintext
Raw Normal View History

/+ default-agent
2020-06-16 10:29:17 +03:00
/+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln
2019-09-05 01:44:22 +03:00
|%
2020-06-16 10:29:17 +03:00
+$ state
$: %7
drum=state:drum
helm=state:helm
kiln=state:kiln
==
+$ any-state
$% state
[ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)]
==
+$ any-state-tuple
$: drum=any-state:drum
helm=any-state:helm
kiln=any-state:kiln
==
+$ fin-any-state
$% [%drum any-state:drum]
[%helm any-state:helm]
[%kiln any-state:kiln]
[%write *] :: gets deleted
==
2019-09-05 01:44:22 +03:00
--
2020-06-16 10:29:17 +03:00
^- agent:gall
=| =state
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bol)
drum-core (drum bowl drum.state)
helm-core (helm bowl helm.state)
kiln-core (kiln bowl kiln.state)
::
++ on-fail on-fail:def
++ on-init
^- step:agent:gall
=^ d drum.state on-init:drum-core
[d this]
2020-06-16 10:29:17 +03:00
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-save !>(state)
2019-11-07 09:19:32 +03:00
++ on-load
2019-09-05 01:44:22 +03:00
|= =old-state=vase
^- step:agent:gall
=+ !<(old=any-state old-state-vase)
=/ tup=any-state-tuple
?+ -.old +.old
?(%1 %2 %3 %4 %5 %6)
:* =-(?>(?=(%drum -<) ->) (~(got by lac.old) %drum))
=-(?>(?=(%helm -<) ->) (~(got by lac.old) %helm))
=-(?>(?=(%kiln -<) ->) (~(got by lac.old) %kiln))
==
==
=/ ver -:*state
=^ d drum.state (on-load:drum-core ver drum.tup)
=^ h helm.state (on-load:helm-core ver helm.tup)
=^ k kiln.state (on-load:kiln-core ver kiln.tup)
[(weld d h k) this]
2019-09-05 01:44:22 +03:00
::
2019-11-07 09:19:32 +03:00
++ on-poke
2019-09-05 01:44:22 +03:00
|= [=mark =vase]
2020-06-16 10:29:17 +03:00
^- step:agent:gall
|^
2020-06-16 10:29:17 +03:00
=/ fin (end 3 4 mark)
?: =(%drum fin) poke-drum
?: =(%helm fin) poke-helm
?: =(%kiln fin) poke-kiln
2020-06-16 10:29:17 +03:00
::
?+ mark (on-poke:def mark vase)
%atom poke-helm(mark %helm-atom)
%dill-belt poke-drum(mark %drum-dill-belt)
%dill-blit poke-drum(mark %drum-dill-blit)
%hood-sync poke-kiln(mark %kiln-sync)
%write-sec-atom poke-helm(mark %helm-write-sec-atom)
2020-06-16 10:29:17 +03:00
==
++ poke-drum =^(c drum.state (poke:drum-core mark vase) [c this]))
++ poke-helm =^(c helm.state (poke:helm-core mark vase) [c this]))
++ poke-kiln =^(c kiln.state (poke:kiln-core mark vase) [c this]))
2020-06-16 10:29:17 +03:00
--
2019-09-05 01:44:22 +03:00
::
2019-11-07 09:19:32 +03:00
++ on-watch
2019-09-06 06:01:31 +03:00
|= =path
2020-06-16 10:29:17 +03:00
^- step:agent:gall
?+ path (on-watch:def +<)
[%drum *] =^(c drum.state (peer:drum-core +<) [c this])
==
2019-09-05 01:44:22 +03:00
::
2019-11-07 09:19:32 +03:00
++ on-agent
2019-11-19 07:36:21 +03:00
|= [=wire =sign:agent:gall]
2020-06-16 10:29:17 +03:00
^- step:agent:gall
?+ wire ~|([%hood-bad-wire wire] !!)
[%drum *] =^(c drum.state (take-agent:drum-core +<) [c this]))
[%helm *] =^(c helm.state (take-agent:helm-core +<) [c this]))
[%kiln *] =^(c kiln.state (take-agent:kiln-core +<) [c this]))
==
2019-09-05 01:44:22 +03:00
::
2019-11-07 09:19:32 +03:00
++ on-arvo
|= [=wire =sign-arvo]
2020-06-16 10:29:17 +03:00
^- step:agent:gall
?+ wire ~|([%hood-bad-wire wire] !!)
[%drum *] =^(c drum.state (take-arvo:drum-core +<) [c this]))
[%helm *] =^(c helm.state (take-arvo:helm-core +<) [c this]))
[%kiln *] =^(c kiln.state (take-arvo:kiln-core +<) [c this]))
==
2019-09-05 01:44:22 +03:00
--