2019-11-15 03:39:28 +03:00
|
|
|
/- eth-watcher
|
2020-12-06 03:20:42 +03:00
|
|
|
/+ ethereum, azimuth, default-agent, verb
|
2020-12-08 03:47:06 +03:00
|
|
|
=, jael
|
2019-11-15 03:39:28 +03:00
|
|
|
|%
|
|
|
|
++ app-state
|
|
|
|
$: %0
|
|
|
|
url=@ta
|
|
|
|
whos=(set ship)
|
|
|
|
==
|
|
|
|
+$ poke-data
|
|
|
|
$% :: %listen
|
|
|
|
::
|
|
|
|
[%listen whos=(list ship) =source:jael]
|
|
|
|
:: %watch: configure node url
|
|
|
|
::
|
|
|
|
[%watch url=@ta]
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|%
|
|
|
|
++ topics
|
|
|
|
|= ships=(set ship)
|
|
|
|
^- (list ?(@ux (list @ux)))
|
|
|
|
:: The first topic should be one of these event types
|
|
|
|
::
|
|
|
|
:- => azimuth-events:azimuth
|
|
|
|
:~ broke-continuity
|
|
|
|
changed-keys
|
|
|
|
lost-sponsor
|
|
|
|
escape-accepted
|
|
|
|
==
|
|
|
|
:: If we're looking for a specific set of ships, specify them as
|
|
|
|
:: the second topic. Otherwise don't specify the second topic so
|
|
|
|
:: we will match all ships.
|
|
|
|
::
|
|
|
|
?: =(~ ships)
|
|
|
|
~
|
|
|
|
[(turn ~(tap in ships) ,@) ~]
|
|
|
|
::
|
|
|
|
++ event-logs-to-udiffs
|
|
|
|
|= event-logs=(list =event-log:rpc:ethereum)
|
|
|
|
^- =udiffs:point
|
|
|
|
%+ murn event-logs
|
|
|
|
|= =event-log:rpc:ethereum
|
|
|
|
^- (unit [=ship =udiff:point])
|
|
|
|
?~ mined.event-log
|
|
|
|
~
|
|
|
|
?: removed.u.mined.event-log
|
|
|
|
~& [%removed-log event-log]
|
|
|
|
~
|
|
|
|
=/ =id:block [block-hash block-number]:u.mined.event-log
|
|
|
|
=, azimuth-events:azimuth
|
|
|
|
=, abi:ethereum
|
|
|
|
?: =(broke-continuity i.topics.event-log)
|
|
|
|
=/ who=@ (decode-topics t.topics.event-log ~[%uint])
|
|
|
|
=/ num=@ (decode-results data.event-log ~[%uint])
|
2021-12-08 13:23:35 +03:00
|
|
|
`[who id %rift num %.n]
|
2019-11-15 03:39:28 +03:00
|
|
|
?: =(changed-keys i.topics.event-log)
|
|
|
|
=/ who=@ (decode-topics t.topics.event-log ~[%uint])
|
2019-12-18 03:48:08 +03:00
|
|
|
=/ [enc=octs aut=octs sut=@ud rev=@ud]
|
2019-11-15 03:39:28 +03:00
|
|
|
%+ decode-results data.event-log
|
|
|
|
~[[%bytes-n 32] [%bytes-n 32] %uint %uint]
|
2021-12-08 13:23:35 +03:00
|
|
|
`[who id %keys [rev sut (pass-from-eth:azimuth enc aut sut)] %.n]
|
2019-11-15 03:39:28 +03:00
|
|
|
?: =(lost-sponsor i.topics.event-log)
|
2019-12-18 03:48:08 +03:00
|
|
|
=/ [who=@ pos=@]
|
2019-11-15 03:39:28 +03:00
|
|
|
(decode-topics t.topics.event-log ~[%uint %uint])
|
|
|
|
`[who id %spon ~]
|
|
|
|
?: =(escape-accepted i.topics.event-log)
|
2019-12-18 03:48:08 +03:00
|
|
|
=/ [who=@ wer=@]
|
2019-11-15 03:39:28 +03:00
|
|
|
(decode-topics t.topics.event-log ~[%uint %uint])
|
|
|
|
`[who id %spon `wer]
|
|
|
|
~& [%bad-topic event-log]
|
|
|
|
~
|
|
|
|
::
|
|
|
|
++ jael-update
|
|
|
|
|= =udiffs:point
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (list card:agent:gall)
|
2020-12-05 10:08:47 +03:00
|
|
|
:- [%give %fact ~[/] %azimuth-udiffs !>(udiffs)]
|
|
|
|
|- ^- (list card:agent:gall)
|
2019-11-15 03:39:28 +03:00
|
|
|
?~ udiffs
|
|
|
|
~
|
|
|
|
=/ =path /(scot %p ship.i.udiffs)
|
2020-12-05 10:08:47 +03:00
|
|
|
:: Should really give all diffs involving each ship at the same time
|
|
|
|
::
|
|
|
|
:- [%give %fact ~[path] %azimuth-udiffs !>(~[i.udiffs])]
|
|
|
|
$(udiffs t.udiffs)
|
2019-11-15 03:39:28 +03:00
|
|
|
::
|
|
|
|
++ start
|
|
|
|
|= [state=app-state our=ship dap=term]
|
2019-11-19 07:36:21 +03:00
|
|
|
^- card:agent:gall
|
2019-11-15 03:39:28 +03:00
|
|
|
=/ args=vase !>
|
eth-watcher: separate timeout from refresh-rate
Previously, when the refresh-rate timer activated, and the thread from
the previous activation was still running, we would kill it and start
a new one. For low refresh rates, on slower machines, nodes, or network
connections, this could cause the update to never conclude.
Here we add a timeout-time to eth-watcher's config. If the refresh-rate
timer activates, and a thread exists, but hasn't been running for at
least the specified timeout-time yet, we simply take no action, and wait
for the next refresh timer.
Note that we opted for "at least timeout-time", instead of killing &
restarting directly after the specified timeout-time has passed, to
avoid having to handle an extra timer flow.
In the +on-load logic, we configure the timeout-time for existing
watchdogs as six times the refresh-rate. We want to set
azimuth-tracker's timeout-time to ~m30, and don't care much about other,
less-likely-to-be-active use cases of eth-watcher.
2020-04-01 13:41:04 +03:00
|
|
|
:+ %watch /[dap]
|
|
|
|
^- config:eth-watcher
|
|
|
|
:* url.state =(%czar (clan:title our)) ~m5 ~m30
|
2019-12-09 22:41:01 +03:00
|
|
|
launch:contracts:azimuth
|
2022-04-06 15:04:05 +03:00
|
|
|
~
|
2019-11-15 03:39:28 +03:00
|
|
|
~[azimuth:contracts:azimuth]
|
2021-04-15 11:02:58 +03:00
|
|
|
~
|
2019-11-15 03:39:28 +03:00
|
|
|
(topics whos.state)
|
|
|
|
==
|
|
|
|
[%pass /wa %agent [our %eth-watcher] %poke %eth-watcher-poke args]
|
|
|
|
--
|
|
|
|
::
|
|
|
|
=| state=app-state
|
2019-11-16 00:02:37 +03:00
|
|
|
%+ verb |
|
2019-11-19 07:36:21 +03:00
|
|
|
^- agent:gall
|
|
|
|
|_ =bowl:gall
|
2019-11-15 03:39:28 +03:00
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
|
|
|
++ on-init
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall agent:gall)
|
2019-11-15 03:39:28 +03:00
|
|
|
:_ this :_ ~
|
2019-11-19 07:36:21 +03:00
|
|
|
^- card:agent:gall
|
2019-11-15 03:39:28 +03:00
|
|
|
[%pass /eth-watcher %agent [our.bowl %eth-watcher] %watch /logs/[dap.bowl]]
|
|
|
|
::
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
`this(state !<(app-state old))
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
?. ?=(%azimuth-tracker-poke mark)
|
|
|
|
(on-poke:def mark vase)
|
|
|
|
=+ !<(poke=poke-data vase)
|
|
|
|
?- -.poke
|
|
|
|
%listen [[%pass /lo %arvo %j %listen (silt whos.poke) source.poke]~ this]
|
|
|
|
%watch
|
|
|
|
=. url.state url.poke
|
|
|
|
[[(start state [our dap]:bowl) ~] this]
|
|
|
|
==
|
2019-12-05 04:58:00 +03:00
|
|
|
::
|
2019-11-15 03:39:28 +03:00
|
|
|
++ on-watch
|
|
|
|
|= =path
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-15 03:39:28 +03:00
|
|
|
?< =(/sole/drum path)
|
|
|
|
?> ?=(?(~ [@ ~]) path)
|
|
|
|
=/ who=(unit ship)
|
|
|
|
?~ path ~
|
|
|
|
`(slav %p i.path)
|
|
|
|
=. whos.state
|
|
|
|
?~ who
|
|
|
|
~
|
|
|
|
(~(put in whos.state) u.who)
|
|
|
|
:_ this :_ ~
|
|
|
|
(start state [our dap]:bowl)
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=wire =sign:agent:gall]
|
2019-11-15 03:39:28 +03:00
|
|
|
?. ?=([%eth-watcher ~] wire)
|
|
|
|
(on-agent:def wire sign)
|
|
|
|
?. ?=(%fact -.sign)
|
|
|
|
(on-agent:def wire sign)
|
|
|
|
?. ?=(%eth-watcher-diff p.cage.sign)
|
|
|
|
(on-agent:def wire sign)
|
|
|
|
=+ !<(diff=diff:eth-watcher q.cage.sign)
|
|
|
|
:_ this
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (list card:agent:gall)
|
2019-11-15 03:39:28 +03:00
|
|
|
%- jael-update
|
|
|
|
?- -.diff
|
|
|
|
%history (event-logs-to-udiffs loglist.diff)
|
2020-12-05 10:08:47 +03:00
|
|
|
%logs (event-logs-to-udiffs loglist.diff)
|
2019-11-15 03:39:28 +03:00
|
|
|
%disavow [*ship id.diff %disavow ~]~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|