mirror of
https://github.com/urbit/shrub.git
synced 2024-11-23 20:26:54 +03:00
ames: make key acquisition asynchronous
This commit is contained in:
parent
13964e27e9
commit
39105cfeed
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:feaae0eece54db3e92122263706c283674af581d14ffde8a29fb24e1873a35b1
|
||||
size 6453015
|
||||
oid sha256:38f5a8c55b699c99a8fa2e0315ed0a63ba80e4c1c18dcbb85b3af3c4bf1e36f0
|
||||
size 6786502
|
||||
|
@ -490,7 +490,8 @@
|
||||
%+ roll cards.r
|
||||
|= [=card cards=(list card) s=_state]
|
||||
:_ =? scrying.s ?=([%pass ^ %arvo %a %keen @ *] card)
|
||||
(~(put ju scrying.s) tid [&2 &6 |6]:card)
|
||||
:: wire ship path
|
||||
scrying.s :: (~(put ju scrying.s) tid [&2 +>+>+>]:card)
|
||||
s
|
||||
:_ cards
|
||||
^- ^card
|
||||
|
@ -801,11 +801,11 @@
|
||||
[%kroc bones=(list [ship bone])]
|
||||
$>(%plea vane-task)
|
||||
[%deep =deep]
|
||||
[%lock ~]
|
||||
::
|
||||
[%keen spar]
|
||||
[%keen secret=? spar]
|
||||
[%yawn spar]
|
||||
[%wham spar]
|
||||
[%plug ~]
|
||||
::
|
||||
$>(%born vane-task)
|
||||
$>(%init vane-task)
|
||||
@ -843,6 +843,7 @@
|
||||
[%lost ~]
|
||||
[%send =lane =blob]
|
||||
::
|
||||
[%stub num=@ud key=@]
|
||||
[%tune spar roar=(unit roar)]
|
||||
::
|
||||
[%turf turfs=(list turf)]
|
||||
|
@ -1205,8 +1205,9 @@
|
||||
+$ task-11-and-16
|
||||
$+ task-11-and-16
|
||||
$% [%kroc dry=?]
|
||||
[%keen spar]
|
||||
[%snub ships=(list ship)]
|
||||
$<(?(%snub %kroc) task)
|
||||
$<(?(%snub %kroc %keen) task)
|
||||
==
|
||||
::
|
||||
+$ queued-event-16
|
||||
@ -1218,7 +1219,20 @@
|
||||
+$ task-16
|
||||
$+ task-16
|
||||
$% [%kroc dry=?]
|
||||
$<(%kroc task)
|
||||
[%keen spar]
|
||||
$<(?(%kroc %keen) task)
|
||||
==
|
||||
::
|
||||
+$ queued-event-17
|
||||
$+ queued-event-17
|
||||
$% [%call =duct wrapped-task=(hobo task-17)]
|
||||
[%take =wire =duct =sign]
|
||||
==
|
||||
::
|
||||
+$ task-17
|
||||
$+ task-17
|
||||
$% [%keen spar]
|
||||
$<(%keen task)
|
||||
==
|
||||
:: $bug: debug printing configuration
|
||||
::
|
||||
@ -1587,7 +1601,7 @@
|
||||
== ==
|
||||
$: %17
|
||||
$% $: %larva
|
||||
events=(qeu queued-event)
|
||||
events=(qeu queued-event-17)
|
||||
state=ames-state-17
|
||||
==
|
||||
[%adult state=ames-state-17]
|
||||
@ -1671,7 +1685,7 @@
|
||||
[%10 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%10 state.old]
|
||||
=. queued-events (event-11-to-17 events.old)
|
||||
=. queued-events (event-11-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%11 %adult *]
|
||||
@ -1682,7 +1696,7 @@
|
||||
[%11 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%11 state.old]
|
||||
=. queued-events (event-11-to-17 events.old)
|
||||
=. queued-events (event-11-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%12 %adult *]
|
||||
@ -1693,7 +1707,7 @@
|
||||
[%12 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%12 state.old]
|
||||
=. queued-events (event-16-to-17 events.old)
|
||||
=. queued-events (event-16-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%13 %adult *]
|
||||
@ -1704,7 +1718,7 @@
|
||||
[%13 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%13 state.old]
|
||||
=. queued-events (event-16-to-17 events.old)
|
||||
=. queued-events (event-16-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%14 %adult *]
|
||||
@ -1715,7 +1729,7 @@
|
||||
[%14 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%14 state.old]
|
||||
=. queued-events (event-16-to-17 events.old)
|
||||
=. queued-events (event-16-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%15 %adult *]
|
||||
@ -1726,7 +1740,7 @@
|
||||
[%15 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%15 state.old]
|
||||
=. queued-events (event-16-to-17 events.old)
|
||||
=. queued-events (event-16-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%16 %adult *]
|
||||
@ -1737,7 +1751,7 @@
|
||||
[%16 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%16 state.old]
|
||||
=. queued-events (event-16-to-17 events.old)
|
||||
=. queued-events (event-16-to-18 events.old)
|
||||
larval-gate
|
||||
::
|
||||
[%17 %adult *]
|
||||
@ -1748,7 +1762,7 @@
|
||||
[%17 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. cached-state `[%17 state.old]
|
||||
=. queued-events events.old
|
||||
=. queued-events (event-17-to-18 events.old)
|
||||
larval-gate
|
||||
|
||||
::
|
||||
@ -1775,7 +1789,7 @@
|
||||
wrapped-task ?.(?=(%snub -.task) task [%snub %deny ships.task])
|
||||
==
|
||||
::
|
||||
++ event-11-to-17
|
||||
++ event-11-to-18
|
||||
|= events=(qeu queued-event-11-and-16)
|
||||
^- (qeu queued-event)
|
||||
%- ~(rep in events)
|
||||
@ -1788,10 +1802,11 @@
|
||||
?+ -.task task
|
||||
%snub [%snub %deny ships.task]
|
||||
%kroc [%kroc ~]
|
||||
%keen [%keen | +.task]
|
||||
==
|
||||
==
|
||||
::
|
||||
++ event-16-to-17
|
||||
++ event-16-to-18
|
||||
|= events=(qeu queued-event-16)
|
||||
^- (qeu queued-event)
|
||||
%- ~(rep in events)
|
||||
@ -1799,8 +1814,25 @@
|
||||
%- ~(put to q) ^- queued-event
|
||||
?. ?=(%call -.e) e
|
||||
=/ task=task-16 ((harden task-16) wrapped-task.e)
|
||||
%= e
|
||||
wrapped-task ?.(?=(%kroc -.task) task [%kroc ~])
|
||||
%= e
|
||||
wrapped-task
|
||||
^- ^task
|
||||
?+ -.task task
|
||||
%kroc [%kroc ~]
|
||||
%keen [%keen | +.task]
|
||||
==
|
||||
==
|
||||
::
|
||||
++ event-17-to-18
|
||||
|= events=(qeu queued-event-17)
|
||||
^- (qeu queued-event)
|
||||
%- ~(rep in events)
|
||||
|= [e=queued-event-17 q=(qeu queued-event)]
|
||||
%- ~(put to q) ^- queued-event
|
||||
?. ?=(%call -.e) e
|
||||
=/ task=task-17 ((harden task-17) wrapped-task.e)
|
||||
%= e
|
||||
wrapped-task ?.(?=(%keen -.task) task [%keen | +.task])
|
||||
==
|
||||
--
|
||||
:: +molt: re-evolve to adult-ames
|
||||
@ -2912,15 +2944,17 @@
|
||||
:: +on-vega: handle kernel reload
|
||||
::
|
||||
++ on-vega event-core
|
||||
:: +on-lock: handle key reservation
|
||||
++ on-lock
|
||||
:: +on-plug: handle key reservation
|
||||
++ on-plug
|
||||
^+ event-core
|
||||
=/ key (shaz eny)
|
||||
~& chain/chain.ames-state
|
||||
=/ idx .+(-:(need (ram:on:chain chain.ames-state)))
|
||||
=/ key=@ (shaz eny) :: TODO: check key width
|
||||
=/ num=@ud
|
||||
?~ latest=(ram:on:chain chain.ames-state)
|
||||
0
|
||||
key.u.latest
|
||||
=. chain.ames-state
|
||||
(put:on:chain chain.ames-state idx key)
|
||||
event-core
|
||||
(put:on:chain chain.ames-state num key)
|
||||
(emit duct %give %stub num key)
|
||||
:: +on-trim: handle request to free memory
|
||||
::
|
||||
:: %ruin comets not seen for six months
|
||||
@ -2944,7 +2978,7 @@
|
||||
+| %fine-entry-points
|
||||
::
|
||||
++ on-keen
|
||||
|= spar
|
||||
|= [secret=? spar]
|
||||
^+ event-core
|
||||
=+ ~:(spit path) :: assert length
|
||||
=/ ship-state (~(get by peers.ames-state) ship)
|
||||
@ -5019,7 +5053,7 @@
|
||||
%tame (on-tame:event-core ship.task)
|
||||
%kroc (on-kroc:event-core bones.task)
|
||||
%deep (on-deep:event-core deep.task)
|
||||
%lock on-lock:event-core
|
||||
%plug on-plug:event-core
|
||||
::
|
||||
%keen (on-keen:event-core +.task)
|
||||
%yawn (on-cancel-scry:event-core | +.task)
|
||||
|
@ -106,6 +106,7 @@
|
||||
sky=(map spur path-state)
|
||||
ken=(jug spar:ames wire)
|
||||
cop=(map coop hutch)
|
||||
hat=(jug coop [path page])
|
||||
== ==
|
||||
::
|
||||
+$ path-state
|
||||
@ -202,6 +203,7 @@
|
||||
sky=(map spur path-state)
|
||||
ken=(jug spar:ames wire)
|
||||
cop=(map coop hutch)
|
||||
hat=(jug coop [path page])
|
||||
== ==
|
||||
--
|
||||
:: adult gall vane interface, for type compatibility with pupa
|
||||
@ -613,6 +615,23 @@
|
||||
=. mo-core (mo-give %unto %kick ~)
|
||||
mo-core
|
||||
==
|
||||
++ mo-handle-key
|
||||
~/ %mo-handle-stub
|
||||
|= [=(pole knot) num=@ud key=@]
|
||||
?. ?=([agent=@ nonce=@ rest=*] pole)
|
||||
~& [%mo-handle-key-bad-wire wire]
|
||||
!!
|
||||
=* dap agent.pole
|
||||
=/ yoke (~(get by yokes.state) dap)
|
||||
?. ?=([~ %live *] yoke)
|
||||
%- (slog leaf+"gall: {<dap>} dead, got %stub" ~)
|
||||
mo-core
|
||||
?. =(run-nonce.u.yoke nonce.pole)
|
||||
%- (slog leaf+"gall: got old stub for {<dap>}" ~)
|
||||
mo-core
|
||||
=/ =routes [disclosing=~ attributing=[our /]]
|
||||
=/ ap-core (ap-abed:ap dap routes)
|
||||
ap-abet:(ap-stub:ap-core rest.pole num key)
|
||||
:: +mo-handle-use: handle a typed +sign incoming on /use.
|
||||
::
|
||||
:: (Note that /use implies the +sign should be routed to an agent.)
|
||||
@ -1066,7 +1085,10 @@
|
||||
++ ap-tend
|
||||
|= [=coop =path =page]
|
||||
?. (~(has by cop.yoke) coop)
|
||||
~| no-such-coop/coop !! :: XX: error handling
|
||||
?. (~(has by hat.yoke) coop)
|
||||
~| no-such-coop/coop !! :: XX: error handling
|
||||
=. hat.yoke (~(put ju hat.yoke) coop path page)
|
||||
ap-core
|
||||
=/ =hutch (~(got by cop.yoke) coop)
|
||||
=. chicks.hutch (~(put by chicks.hutch) path page)
|
||||
=. cop.yoke (~(put by cop.yoke) coop hutch)
|
||||
@ -1074,13 +1096,23 @@
|
||||
++ ap-germ
|
||||
|= =coop
|
||||
=/ key=@uvJ (shax eny) :: TODO: review key generation
|
||||
=/ =hutch
|
||||
?~ hut=(~(get by cop.yoke) coop)
|
||||
*hutch :: TODO: fix
|
||||
=. lock.u.hut *lock
|
||||
u.hut
|
||||
=/ hut (~(get by cop.yoke) coop)
|
||||
=? hat.yoke ?=(~ hut)
|
||||
(~(put by hat.yoke) coop ~)
|
||||
=/ =wire (welp /key/[agent-name]/[run-nonce.yoke] coop)
|
||||
(ap-move [hen %pass wire %a %plug ~]~)
|
||||
::
|
||||
++ ap-stub
|
||||
|= [=coop num=@ud key=@]
|
||||
^+ ap-core
|
||||
=/ =hutch
|
||||
(~(gut by cop.yoke) coop *hutch)
|
||||
=. lock.hutch [.+(rev.lock.hutch) num]
|
||||
=. cop.yoke (~(put by cop.yoke) coop hutch)
|
||||
ap-core
|
||||
=/ hat ~(tap in (~(get ju hat.yoke) coop))
|
||||
|- ^+ ap-core
|
||||
?~ hat ap-core
|
||||
$(hat t.hat, ap-core (ap-tend coop i.hat))
|
||||
::
|
||||
++ ap-snip
|
||||
|= =coop
|
||||
@ -1433,7 +1465,7 @@
|
||||
%- zing
|
||||
%+ turn ~(tap by `(jug spar:ames wire)`ken.yoke)
|
||||
|= [=spar:ames wyz=(set wire)]
|
||||
(turn ~(tap in wyz) |=(=wire [%pass wire %arvo %a %keen spar]))
|
||||
(turn ~(tap in wyz) |=(=wire [%pass wire %arvo %a %keen | spar]))
|
||||
=^ error ap-core
|
||||
(ap-install(agent.yoke &+agent) `old-state)
|
||||
?~ error
|
||||
@ -1880,7 +1912,7 @@
|
||||
%+ roll fex
|
||||
|= [=carp ken=_ken.yoke]
|
||||
?+ carp ken
|
||||
[%pass * %arvo %a %keen spar=*] (~(put ju ken) [spar.q p]:carp)
|
||||
[%pass * %arvo %a %keen @ spar=*] (~(put ju ken) [spar.q p]:carp)
|
||||
[%pass * %arvo %a %yawn spar=*] (~(del ju ken) [spar.q p]:carp)
|
||||
==
|
||||
:: +ap-handle-kicks: handle cancels of bitt.watches
|
||||
@ -2299,9 +2331,8 @@
|
||||
|= egg=egg-13
|
||||
?: ?=(%nuke -.egg)
|
||||
egg
|
||||
egg(ken [ken.egg ~])
|
||||
egg(ken [ken.egg ~ ~])
|
||||
==
|
||||
|
||||
::
|
||||
++ spore-13-to-14
|
||||
|= old=spore-13
|
||||
@ -2531,6 +2562,10 @@
|
||||
?: =(/clear-huck wire)
|
||||
=/ =gift ?>(?=([%behn %heck %gall *] syn) +>+.syn)
|
||||
[[duct %give gift]~ gall-payload]
|
||||
?: ?=([%key *] wire)
|
||||
~| [%gall-take-key-failed wire]
|
||||
?> ?=([%ames %stub *] syn)
|
||||
mo-abet:(mo-handle-key:(mo-abed:mo duct) t.wire [num key]:syn)
|
||||
::
|
||||
~| [%gall-take-failed wire]
|
||||
?> ?=([?(%sys %use) *] wire)
|
||||
|
@ -335,7 +335,7 @@
|
||||
|= [=wire =spar:ames]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(send-raw-card %pass wire %arvo %a %keen spar)
|
||||
(send-raw-card %pass wire %arvo %a %keen | spar)
|
||||
::
|
||||
++ sleep
|
||||
|= for=@dr
|
||||
|
Loading…
Reference in New Issue
Block a user