jael: give private key to subscribers on keys diff

Triggering this event has been added to /app/azimuth's +on-load
This commit is contained in:
yosoyubik 2022-01-08 09:48:28 +01:00
parent 583d5f5063
commit 8535563de6
3 changed files with 47 additions and 22 deletions

View File

@ -21,7 +21,7 @@
=, jael
|%
+$ app-state
$: %3
$: %4
url=@ta
=net
whos=(set ship)
@ -100,32 +100,41 @@
=^ cards-2 old-state
?. ?=(%2 -.old-state)
`old-state
~& > '%azimuth: updating to state 3'
=. +.state +.old-state
:: replace naive state and indices with snapshot
::
=: nas.old-state nas.snap
own.old-state owners.snap
spo.old-state sponsors.snap
logs.old-state ~
=: nas.state nas.snap
own.state owners.snap
spo.state sponsors.snap
logs.state ~
:: TODO: shouldn't be needed but have seen eth-watcher
:: threads use a url='' if this is not used
::
url.state 'http://eth-mainnet.urbit.org:8545'
==
=/ points=@ud ~(wyt by points.nas.old-state)
=/ points=@ud ~(wyt by points.nas.state)
%- %- slog :_ ~
:- %leaf
"ship: processing azimuth snapshot ({<points>} points)"
=/ snap-cards=udiffs:point (run-state:do id.snap points.nas.old-state)
:_ [%3 +.old-state]
;: welp
cards-1
leaf+"ship: processing azimuth snapshot ({<points>} points)"
=/ snap-cards=udiffs:point (run-state:do id.snap points.nas.state)
:_ [%3 +.state]
%+ weld
(jael-update:do snap-cards)
:: start getting new logs after the last id:block in the snapshot
::
start:do
==
?> ?=(%3 -.old-state)
[cards-2 this(state old-state)]
:: start getting new logs after the last id:block in the snapshot
::
start:do
=^ cards-3 old-state
?. ?=(%3 -.old-state) [cards-2 old-state]
:_ old-state(- %4)
~& > '%azimuth: updating to state 4'
[%pass /resend-pk %arvo %j %resend ~]^cards-2
?> ?=(%4 -.old-state)
[cards-3 this(state old-state)]
::
++ app-states $%(state-0 state-1-2 app-state)
+$ state-1-2
$: ?(%1 %2)
++ app-states $%(state-0 state-1-2-3 app-state)
::
+$ state-1-2-3
$: ?(%1 %2 %3)
url=@ta
=net
whos=(set ship)
@ -257,6 +266,12 @@
%history (welp logs.state loglist.diff)
%logs (welp logs.state loglist.diff)
==
:: doing :azimuth|watch caused a l2-sig-fail when using the eth-log
:: snapshot because we were not updating nas with the saved logs.
::
:: now (L: 189) nas.state is loaded with the contents of the snapshot,
:: if we are on the %default network.
::
=^ effects state (run-logs:do loglist.diff)
:_ this
%+ weld

View File

@ -1906,6 +1906,7 @@
[%private-keys ~] :: sub to privates
[%public-keys ships=(set ship)] :: sub to publics
[%rekey =life =ring] :: update private keys
[%resend ~] :: resend private key
[%ruin ships=(set ship)] :: pretend breach
$>(%trim vane-task) :: trim state
[%turf ~] :: view domains

View File

@ -427,6 +427,13 @@
%- curd =< abet
(private-keys:~(feel su hen now pki etn) life.tac ring.tac)
::
:: resend private key to subscribers
::
%resend
%- curd =< abet
%- ~(exec su hen now pki etn)
[yen.own.pki [%give %private-keys [lyf jaw]:own.pki]]
::
:: register moon keys
::
%moon
@ -740,7 +747,9 @@
?=(%keys -.u.a-diff)
(~(has by jaw.own) life.to.u.a-diff)
==
life.to.u.a-diff
=* lyf life.to.u.a-diff
=. moz [[hen %give %private-keys lyf jaw:own] moz]
lyf
(public-keys:feel original-pos %diff ship.i.udiffs u.a-diff)
$(udiffs t.udiffs)
::