Repository navigation
refactor(explorer): remove the dead node read path and simplify the backend - #13
Merged
Merged
Conversation
…impl layers - Remove data_source = "node" (node_client.rs, node_repository.rs): it called a REST API the node never had, so it could only error or, with strict_mode off, return made-up data. Every deployment runs postgres. strict_mode and clutch_node_api_url go with it; a config that still carries them is unaffected, serde ignores the keys. - Drop the ExplorerRepository trait, ExplorerService wrapper and NodeIngestionSource trait, each with one implementation; handlers call PostgresRepository and the indexer calls NodeSource. - The indexer fetches each block once instead of twice (two get_block_by_index calls per height). - ExplorerError converts from sqlx::Error and renders its own JSON response, replacing ~50 map_err calls and the per-handler error and paging boilerplate. Responses are unchanged. - db.rs runs migrations from one list; Seq logging drops a Mutex that serialised every send. - Frontend: remove the unused .segmented styles and an export nothing imports. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmCzHLuviWNhDk89GeuXDF
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.
Requested by Mehran · project thread
Before: the backend carried a second read path (
data_source = "node") that called a REST API clutch-node never had, three traits with one implementation each, about 50 copies of the samemap_err, and the indexer fetched every block from the node twice.After: one read path (Postgres), no single-implementation layers, one node call per block. The API's responses, the database schema and what the indexer writes are unchanged. Net about 1,200 fewer lines.
The behavior stays the same. This was checked on a local 3-validator clutch-node chain with 8 transfers: the old and new indexers wrote identical rows to every table, and 33 API requests got the same status code and JSON from both (successes, 404s and 400s). The only difference is key order in a few detail responses, which JSON ignores.
How:
node_client.rsandnode_repository.rs, plus thedata_source,strict_modeandclutch_node_api_urlsettings. Every deployment uses postgres. clutch-deploy's configs still set those keys, and serde ignores them, so nothing has to change there before this merges.ExplorerRepositorytrait, theExplorerServicewrapper and theNodeIngestionSourcetrait. Handlers now callPostgresRepository, and the indexer callsNodeSource.NodeSource::fetch_blockreads a block's header, transactions and effects from oneget_block_by_indexcall. Before, there was one call for the header and another for the transactions.ExplorerErrornow converts fromsqlx::Errorand builds its own JSON response. Handlers share the paging and validation helpers. The transaction filter usesQueryBuilderinstead of counting$nplaceholders by hand.db.rsruns migrations from one list. Seq logging no longer locks aMutexaround every send..segmentedCSS and an export nothing imported.CLAUDE.mdto match. It also fixes "ceiling" to "floor" for referrer fees, because the code floors.Checks:
cargo test --all-targets(15 pass),cargo clippyclean,tscandvite buildpass.🤖 Generated with Claude Code
https://claude.ai/code/session_01VmCzHLuviWNhDk89GeuXDF
Generated by Claude Code