Skip to main content

Indexing

PressChain applications need fast search, lists, timelines and relationship queries that raw contract storage is not designed to serve directly. An indexer solves that problem by projecting chain activity into query-friendly storage. The indexer is infrastructure, not a second protocol authority.

Core rule

Every projected canonical fact should be traceable back to chain state or a protocol event. Enrichment can be added, but it must remain distinguishable from canonical data.

Event cursor

Store at least:
For each event, preserve:
This supports idempotency and reorganization recovery.

Replayable ingestion

A production indexer should be able to rebuild from a known start block.
Do not advance the cursor before the projection transaction is durable.

Reorganization handling

Before continuing from a stored cursor, compare the stored block hash with the current network hash for that block. If it differs, walk backward to a known common ancestor, roll back affected projected records and replay. Even when reorganizations are uncommon, implementing the path before production prevents silent data corruption later.

Reconcile mutable state

Events are excellent for discovering changes. View calls are excellent for confirming current state. For important mutable domains such as evidence finalization, contributor active state and role eligibility, periodically reconcile the projection with authoritative reads.

Keep enrichments namespaced

A search index may add language detection, topic labels, ranking or external analytics. Do not store those fields in columns that look indistinguishable from protocol status. A useful pattern is:

Blockscout and custom projections

PressChain Explorer uses Blockscout as a foundation, while product-specific Capsule, evidence and provenance experiences can require additional semantic projections. Do not force every journalism query into a generic transaction table.

Operational metrics

Track head block, indexed block, lag, replay count, RPC error rate, reorg depth, failed event count and reconciliation mismatches. An indexer can be “up” while silently 20,000 blocks behind. Health needs to reflect freshness, not only process availability.