mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
specialize azimuth-tracker to sets of ships
This commit is contained in:
parent
89cde4a272
commit
b19c91dcf0
@ -7,16 +7,18 @@
|
||||
from-number=number:block
|
||||
==
|
||||
+$ app-state
|
||||
$: url=@ta
|
||||
$: %1
|
||||
url=@ta
|
||||
=number:block
|
||||
=pending-udiffs
|
||||
blocks=(list block)
|
||||
whos=(set ship)
|
||||
==
|
||||
+$ peek-data ~
|
||||
+$ in-poke-data
|
||||
$: %azimuth-tracker-poke
|
||||
$% [%init ~]
|
||||
[%listen whos=(set ship) =source:kale]
|
||||
[%listen whos=(list ship) =source:kale]
|
||||
[%watch =config]
|
||||
==
|
||||
==
|
||||
@ -40,13 +42,16 @@
|
||||
::
|
||||
=> |%
|
||||
++ topics
|
||||
=> azimuth-events:azimuth
|
||||
:_ ~
|
||||
:~ broke-continuity
|
||||
changed-keys
|
||||
lost-sponsor
|
||||
escape-accepted
|
||||
==
|
||||
|= ships=(set ship)
|
||||
:- => azimuth-events:azimuth
|
||||
:~ broke-continuity
|
||||
changed-keys
|
||||
lost-sponsor
|
||||
escape-accepted
|
||||
==
|
||||
?: =(~ ships)
|
||||
~
|
||||
[(turn ~(tap in ships) ,@) ~]
|
||||
::
|
||||
++ request-rpc
|
||||
|= [url=@ta id=(unit @t) req=request:rpc:ethereum]
|
||||
@ -177,7 +182,7 @@
|
||||
--
|
||||
::
|
||||
++ get-logs-by-hash
|
||||
|= [url=@ta =hash:block]
|
||||
|= [url=@ta whos=(set ship) =hash:block]
|
||||
=/ m (async:stdio udiffs:point)
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
@ -186,7 +191,7 @@
|
||||
%eth-get-logs-by-hash
|
||||
hash
|
||||
~[azimuth:contracts:azimuth]
|
||||
topics
|
||||
(topics whos)
|
||||
==
|
||||
=/ event-logs=(list event-log:rpc:ethereum)
|
||||
(parse-event-logs:rpc:ethereum json)
|
||||
@ -194,7 +199,7 @@
|
||||
(pure:m udiffs)
|
||||
::
|
||||
++ get-logs-by-range
|
||||
|= [url=@ta =from=number:block =to=number:block]
|
||||
|= [url=@ta whos=(set ship) =from=number:block =to=number:block]
|
||||
=/ m (async:stdio udiffs:point)
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
@ -204,7 +209,7 @@
|
||||
`number+from-number
|
||||
`number+to-number
|
||||
~[azimuth:contracts:azimuth]
|
||||
topics
|
||||
(topics whos)
|
||||
==
|
||||
=/ event-logs=(list event-log:rpc:ethereum)
|
||||
(parse-event-logs:rpc:ethereum json)
|
||||
@ -274,10 +279,10 @@
|
||||
:: Send %listen to kale
|
||||
::
|
||||
++ listen
|
||||
|= [state=app-state whos=(set ship) =source:kale]
|
||||
|= [state=app-state whos=(list ship) =source:kale]
|
||||
=/ m (async:stdio ,app-state)
|
||||
^- form:m
|
||||
;< ~ bind:m (send-effect:stdio %listen /lo whos source)
|
||||
;< ~ bind:m (send-effect:stdio %listen /lo (silt whos) source)
|
||||
(pure:m state)
|
||||
::
|
||||
:: Take %source from kale
|
||||
@ -290,6 +295,7 @@
|
||||
(pure:m state)
|
||||
=/ a-purl=purl:eyre node.p.source
|
||||
=. url.state (crip (en-purl:html a-purl))
|
||||
=. whos.state whos
|
||||
(watch state url.state launch:contracts:azimuth)
|
||||
::
|
||||
:: Start watching a node
|
||||
@ -324,7 +330,8 @@
|
||||
(pure:m state)
|
||||
;< =block bind:m (get-block-by-number url.state number.state)
|
||||
;< [=new=pending-udiffs new-blocks=(lest ^block)] bind:m
|
||||
(take-block url.state pending-udiffs.state block blocks.state)
|
||||
%- take-block
|
||||
[url.state whos.state pending-udiffs.state block blocks.state]
|
||||
=: pending-udiffs.state new-pending-udiffs
|
||||
blocks.state new-blocks
|
||||
number.state +(number.id.i.new-blocks)
|
||||
@ -334,7 +341,7 @@
|
||||
:: Process a block, detecting and handling reorgs
|
||||
::
|
||||
++ take-block
|
||||
|= [url=@ta =a=pending-udiffs =block blocks=(list block)]
|
||||
|= [url=@ta whos=(set ship) =a=pending-udiffs =block blocks=(list block)]
|
||||
=/ m (async:stdio ,[pending-udiffs (lest ^block)])
|
||||
^- form:m
|
||||
~& [%taking id.block]
|
||||
@ -343,7 +350,7 @@
|
||||
(rewind url a-pending-udiffs block blocks)
|
||||
;< =b=pending-udiffs bind:m
|
||||
(release-old-events a-pending-udiffs number.id.block)
|
||||
;< =new=udiffs:point bind:m (get-logs-by-hash url hash.id.block)
|
||||
;< =new=udiffs:point bind:m (get-logs-by-hash url whos hash.id.block)
|
||||
~? !=(~ new-udiffs) [%adding-diffs new-udiffs]
|
||||
=. b-pending-udiffs (~(put by b-pending-udiffs) number.id.block new-udiffs)
|
||||
(pure:m b-pending-udiffs block blocks)
|
||||
@ -396,11 +403,12 @@
|
||||
|= [state=app-state =latest=number:block]
|
||||
=/ m (async:stdio ,number:block)
|
||||
^- form:m
|
||||
?: (lth latest-number (add number.state 500))
|
||||
(pure:m latest-number)
|
||||
=/ to-number=number:block (sub latest-number 500)
|
||||
=/ zoom-margin=number:block 30
|
||||
?: (lth latest-number (add number.state zoom-margin))
|
||||
(pure:m number.state)
|
||||
=/ to-number=number:block (sub latest-number zoom-margin)
|
||||
;< =udiffs:point bind:m
|
||||
(get-logs-by-range url.state number.state to-number)
|
||||
(get-logs-by-range url.state whos.state number.state to-number)
|
||||
;< ~ bind:m (jael-update udiffs)
|
||||
(pure:m to-number)
|
||||
--
|
||||
@ -415,9 +423,9 @@
|
||||
=/ m tapp-async
|
||||
^- form:m
|
||||
?- +<.in-poke-data
|
||||
%init (init state)
|
||||
%listen (listen state +>.in-poke-data)
|
||||
%watch (watch state +>.in-poke-data)
|
||||
%init (init state)
|
||||
%listen (listen state +>.in-poke-data)
|
||||
%watch (watch state +>.in-poke-data)
|
||||
==
|
||||
::
|
||||
++ handle-take
|
||||
|
@ -5,7 +5,7 @@
|
||||
==
|
||||
--
|
||||
:- %say
|
||||
|= [* [whos=(set ship) =src] ~]
|
||||
|= [* [whos=(list ship) =src] ~]
|
||||
=/ =source:kale
|
||||
?- -.src
|
||||
%ship [%& ship.src]
|
||||
|
Loading…
Reference in New Issue
Block a user