shrub/pkg/arvo/sur/eth-watcher.hoon
Philip Monk b9fe6af976
jael: don't signal breach if first hearing of ship
When you first boot, if you try talk to someone before your azimuth is
up-to-date (for example by import), then if they've ever breached
(twice) then you'll get breach notification, cancelling your message.

This changes is it so that if we haven't heard anything about this ship,
we don't signal a breach.

The implementation complexity is primarily because we need
eth-watcher/azimuth-tracker to produce an update of a list instead of a
list of updates.  This way, Jael can keep a "state as of the beginning
of this move" variable to check when deciding whether to signal a
breach.
2020-12-04 23:08:47 -08:00

60 lines
1.4 KiB
Plaintext

:: eth-watcher: ethereum event log collector
::
=, able:jael
|%
+$ config
$: :: url: ethereum node rpc endpoint
:: eager: if true, give logs asap, send disavows in case of reorg
:: refresh-rate: rate at which to check for updates
:: timeout-time: time an update check is allowed to take
:: from: oldest block number to look at
:: contracts: contract addresses to look at
:: topics: event descriptions to look for
::
url=@ta
eager=?
refresh-rate=@dr
timeout-time=@dr
from=number:block
contracts=(list address:ethereum)
=topics
==
::
+$ loglist (list event-log:rpc:ethereum)
+$ topics (list ?(@ux (list @ux)))
+$ watchpup
$: config
=number:block
=pending-logs
blocks=(list block)
==
::
:: disavows: newest block first
+$ disavows (list id:block)
+$ pending-logs (map number:block loglist)
::
+$ poke
$% :: %watch: configure a watchdog and fetch initial logs
::
[%watch =path =config]
:: %clear: remove a watchdog
::
[%clear =path]
==
::
+$ diff
$% :: %history: full event log history, oldest first
::
[%history =loglist]
:: %log: newly added log
::
[%logs =loglist]
:: %disavow: forget logs
::
:: this is sent when a reorg happens that invalidates
:: previously-sent logs
::
[%disavow =id:block]
==
--