Repository navigation
Add BlockHandler hooks to the sync engine - #54
Merged
Merged
Conversation
An optional, chain-data-agnostic hook for deriving additional state from synced data, in lockstep with the canonical tables: - on_block runs inside the same transaction that writes blocks/txs/logs (before copy_logs consumes them), so derived state commits atomically with the batch. - on_rollback mirrors a reorg delete with the first removed block number, so derived state reverts in the same transaction as the canonical delete. Attach via Downloader::with_handler. No behavior change when unused; golden-axe knows nothing about what a handler derives (app-specific projections, aggregates, etc.). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An optional, chain-data-agnostic hook for deriving additional state from synced data, in lockstep with the canonical tables — for embedders using golden-axe as a library who want derived state (app-specific projections, decoded views, aggregates) without forking the sync loop.
on_blockruns inside the same transaction that writes blocks/txs/logs (invoked beforecopy_logsconsumes the batch), so whatever a handler derives commits atomically with the canonical data.on_rollbackmirrors a reorg delete: called with the first removed block number inside the same transaction asdelete_after's deletes, so derived state reverts in lockstep with the canonical tables.Attach via
Downloader::with_handler(...); with no handler attached (the default), behavior is unchanged. Adds anasync-traitdependency tobe.We've been running this in production against Base Sepolia (a downstream consumer deriving reduced state from logs) — the transactional coupling has held up through backfill, live tailing, and reorg paths.
🤖 Generated with Claude Code