You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(node): WatcherConfig builder with defaults + shared metric-hook helper across the six LogSink watchers #1251
The watcher engine is already unified (one resumable_watcher::run driving all six LogSink impls after #1092/#1106/#1225/#1226/#1234), but each of the six construction sites still writes a ~25-line WatcherConfig struct literal where ~10 fields are constants or near-constants (max_backfill_span: MAX_BACKFILL_BLOCK_SPAN, initial_backoff: WATCHER_INITIAL_BACKOFF, max_backoff: WATCHER_MAX_BACKOFF, rpc_call_timeout: None, seed_cursor: None, from_block: 0, …):
reputation_indexer.rs:107
capacity_bond_registry.rs:387
payment_settlement.rs:294
slash_watcher.rs:154
blacklist_watcher.rs:234
chain_origin_directory.rs:344
On top of that, seven near-identical Box::new(move || metrics.xxx()) closures implement established_hook/backoff_hook/rpc_failure_hook across slash_watcher (slash_watcher.rs:218-232), capacity_bond_registry (capacity_bond_registry.rs:318-327), chain_origin_directory (chain_origin_directory.rs:596-605), and reputation_indexer (reputation_indexer.rs:141).
Proposed fix
WatcherConfig builder (or Default + struct-update syntax) so each site specifies only filter, cursor policy, label, and hooks.
A small metric_hook(metrics, |m| m.foo()) helper deduping the seven hook closures.
~100-150 prod lines. Pure construction sugar — the loop semantics in resumable_watcher.rs are untouched, and every site is already covered by its watcher tests.
Note: cursor-policy fields are being reshaped in #1238 — coordinate so the builder lands on the post-#1238 field set rather than freezing the current one.
Activity
refactor(node): WatcherConfig builder with defaults + shared metric-h…