urbit/pkg/arvo/sur/eth-watcher.hoon

61 lines
1.4 KiB
Plaintext
Raw Normal View History

2019-10-29 22:51:58 +03:00
:: eth-watcher: ethereum event log collector
::
/+ ethereum
2020-12-08 03:47:06 +03:00
=, jael
2019-10-29 22:51:58 +03:00
|%
+$ 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
2019-10-29 22:51:58 +03:00
from=number:block
contracts=(list address:ethereum)
=topics
==
::
+$ loglist (list event-log:rpc:ethereum)
+$ topics (list ?(@ux (list @ux)))
2019-11-12 08:36:32 +03:00
+$ watchpup
$: config
=number:block
=pending-logs
blocks=(list block)
==
::
:: disavows: newest block first
+$ disavows (list id:block)
+$ pending-logs (map number:block loglist)
2019-10-29 22:51:58 +03:00
::
+$ 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
2019-10-29 22:51:58 +03:00
::
[%history =loglist]
2020-12-06 02:17:37 +03:00
:: %logs: newly added logs
2019-10-29 22:51:58 +03:00
::
[%logs =loglist]
2019-10-29 22:51:58 +03:00
:: %disavow: forget logs
::
:: this is sent when a reorg happens that invalidates
:: previously-sent logs
::
[%disavow =id:block]
==
--