-
Notifications
You must be signed in to change notification settings - Fork 170
feat(indexer): replace polling with Stellar RPC event fetching #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ritik4ever
merged 2 commits into
ritik4ever:main
from
MJ-RWA:feat/stellar-rpc-event-subscription-indexer
Jul 31, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| -- Migration down: 0003_add_indexer_cursor | ||
| -- Purpose : Remove the indexer checkpoint table. | ||
|
|
||
| DROP TABLE IF EXISTS indexer_cursor; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| -- Migration: 0003_add_indexer_cursor | ||
| -- Purpose : Add an indexer checkpoint table to persist the last | ||
| -- successfully processed ledger sequence. This allows | ||
| -- the indexer to resume from the correct position after | ||
| -- a restart, preventing event loss and duplicate processing. | ||
| -- Safe to run multiple times: uses CREATE TABLE IF NOT EXISTS | ||
| -- and a singleton row pattern (id = 1). | ||
|
|
||
| CREATE TABLE IF NOT EXISTS indexer_cursor ( | ||
| id INTEGER PRIMARY KEY CHECK (id = 1), | ||
| last_ledger_sequence INTEGER NOT NULL | ||
| ); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import Database from "better-sqlite3"; | ||
|
|
||
| export function up(db: Database.Database): void { | ||
| db.exec(` | ||
| CREATE TABLE IF NOT EXISTS indexer_cursor ( | ||
| id INTEGER PRIMARY KEY CHECK (id = 1), | ||
| last_ledger_sequence INTEGER NOT NULL | ||
| ); | ||
| `); | ||
| } | ||
|
|
||
| export function down(db: Database.Database): void { | ||
| db.exec(`DROP TABLE IF EXISTS indexer_cursor;`); | ||
| } | ||
|
|
||
| if (require.main === module) { | ||
| const dbPath = process.env.DB_PATH ?? "backend/data/streams.db"; | ||
| const db = new Database(dbPath); | ||
| up(db); | ||
| db.close(); | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Fallback poll interval minimum disagrees across docs, schema, and runtime floor (5000ms vs 1000ms).
backend/.env.exampledocuments a 5000ms minimum, butbackend/src/config/validateEnv.ts's Zod schema enforces>= 1000andbackend/src/services/indexer.ts's runtime floor isMath.max(1000, ...)— both consistent with each other at 1000ms, but not with the documented 5000ms.backend/src/config/validateEnv.ts#L58-L65: either update the.refine(val >= 1000, ...)check (and message) to>= 5000if 5000ms is the intended floor, or update the.env.examplecomment to say 1000ms if 1000ms is intended.backend/.env.example#L39-L41: update the "minimum 5000" comment to match whichever floor is chosen invalidateEnv.ts.backend/src/services/indexer.ts#L105-L107: updateMath.max(1000, FALLBACK_POLL_INTERVAL_MS)to use the same floor constant asvalidateEnv.ts(ideally sourced from one shared constant) so all three stay in sync.📍 Affects 3 files
backend/src/config/validateEnv.ts#L58-L65(this comment)backend/.env.example#L39-L41backend/src/services/indexer.ts#L105-L107🤖 Prompt for AI Agents