azimuth+roller: add get-naive/predicted-state

This commit is contained in:
yosoyubik 2021-09-05 12:36:19 +02:00
parent 96789d1aab
commit 7e0c99c980
5 changed files with 49 additions and 2 deletions

View File

@ -146,8 +146,9 @@
[~ ~(parse error:json-rpc id)]
=/ method=@tas (enkebab method)
?+ method [~ ~(method error:json-rpc id)]
%get-point `(get-point id +.params point:scry)
%get-dns `(get-dns id +.params dns:scry)
%get-point `(get-point id +.params point:scry)
%get-dns `(get-dns id +.params dns:scry)
%get-naive-state `(get-naive id +.params naive-state:scry)
==
--
::
@ -165,5 +166,11 @@
%gx
(~(scry agentio bowl) %azimuth /dns/noun)
==
::
++ naive-state
.^ ^state:naive
%gx
(~(scry agentio bowl) %azimuth /nas/noun)
==
--
--

View File

@ -142,6 +142,7 @@
[%x %own ~] ``noun+!>(own.state)
[%x %point @ ~] ``noun+(point i.t.t.path)
==
::
++ point
|= wat=@t
^- vase

View File

@ -167,6 +167,7 @@
%get-history `(history id +.params addr:history:scry)
%get-roller-config `(get-config id +.params config:scry)
%hash-transaction `(hash-transaction id +.params chain-id:scry)
%get-predicted-state `(get-naive id +.params predicted:scry)
==
--
::
@ -306,5 +307,11 @@
%roller
/chain-id/noun
==
::
++ predicted
.^ ^state:naive
%gx
(~(scry agentio bowl) %roller /predicted/noun)
==
--
--

View File

@ -164,6 +164,7 @@
:: /x/manager -> %noun (list ship)
:: /x/voting -> %noun (list ship)
:: /x/spawning -> %noun (list ship)
:: /x/predicted -> %noun state:naive
::
++ on-peek
|= =path
@ -187,6 +188,7 @@
[%x %manager @ ~] (points-proxy %manage i.t.t.path)
[%x %voting @ ~] (points-proxy %vote i.t.t.path)
[%x %spawning @ ~] (points-proxy %spawn i.t.t.path)
[%x %predicted ~] ``noun+!>(pre)
==
::
++ pending-by

View File

@ -361,6 +361,29 @@
|= [p=@ q=@]
^- json
s+(crip ['0' 'x' ((x-co:co (mul 2 p)) q)])
::
++ naive-state
|= =^state:naive
^- json
|^
%- pairs
:~ ['points' (points (tap:orm:naive points.state))]
['operators' (operators operators.state)]
['dns' a+(turn dns.state (cork same (lead %s)))]
==
::
++ operators
|= =operators:naive
^- json
:- %a
%+ turn ~(tap by operators)
|= [op=@ux addrs=(set @ux)]
^- json
%- pairs
:~ ['operator' (hex 20 op)]
['addresses' a+(turn ~(tap in addrs) (cury hex 20))]
==
--
--
::
++ to-hex
@ -567,4 +590,11 @@
:+ %result id
=- (hex:to-json 32 (hash-tx:lib p q))
(unsigned-tx:lib chain-id u.nonce (gen-tx-octs:lib u.tx))
::
++ get-naive
|= [id=@t params=(map @t json) =^state:naive]
^- response:rpc
?. =((lent ~(tap by params)) 0)
~(params error:json-rpc id)
[%result id (naive-state:to-json state)]
--