Actually retain state across iterations.
::
++ ta-read-ships
|= who=(list @p)
- ~& [%ta-read-ships ~(key by ships)]
- %^ spir who this
- |=([p=@p _this] (ta-read %ships p))
+ ?~ who this
+ $(who t.who, this (ta-read %ships i.who))
::
::
++ ta-init
%- ta-read-ships(wir /init)
- (gulf ~zod ~per) ::TODO ~fes)
+ (gulf ~zod ~nec) ::TODO ~fes)
::
- ++ ta-init-result
+ ++ ta-init-results
|= rep=response:json-rpc
^+ this
?> ?=(%batch -.rep)
=. wir /init
- %^ spir bas.rep this
- |= [r=response:json-rpc this=_this]
- ^+ this
- ?< ?=(%batch -.r)
- ~& id.r
- ?: ?=(%error -.r)
- ~& [%rpc-error message.r]
- this
- ?> ?=(%s -.res.r)
+ |- ^+ +>.^$
+ ?~ bas.rep +>.^$
+ =. +>.^$ (ta-init-result i.bas.rep)
+ $(bas.rep t.bas.rep)
+ ::
+ ++ ta-init-result
+ |= rep=response:json-rpc
+ ?< ?=(%batch -.rep)
+ ~& id.rep
+ ?: ?=(%error -.rep)
+ ~& [%rpc-error message.rep]
+ ::TODO retry or something
+ +>.$
+ ?> ?=(%s -.res.rep)
=/ hul=hull:eth-noun
- (decode-results p.res.r hull:eth-type)
- ?. active.hul this
+ (decode-results p.res.rep hull:eth-type)
+ ?. active.hul +>.$
=/ who=@p
- %+ rash id.r
+ %+ rash id.rep
(ifix [(jest 'ships(~') (just ')')] fed:ag)
=. ships
%+ ~(put by ships) who
(hull-from-eth hul)
- ~& [%stored ~(key by ships)]
(ta-read-ships (kids who))
--
::
-(p.p |)
--
::
-++ spir
- :>
- :> a: list
- :> b: state
- :> c: gate from list-item and state to new state
- :> produces: new state
- |* [a=(list) b=* c=_|=(^ +<+)]
- => .(c `$-([_?>(?=(^ a) i.a) _b] _b)`c)
- :> transformed list and updated state
- |- ^+ b
- ?~ a b
- $(a t.a, b (c i.a b))
-::
++ kids
|= pre=@p
^- (list @p)
++ sigh-json-rpc-response-init
|= [w=wire r=response:json-rpc]
~& %got-init-response
- ta-save:(ta-init-result:ta r)
+ ta-save:(ta-init-results:ta r)
::
++ sigh-json-rpc-response
|= [w=wire r=response:json-rpc]
