Skip to content

Stellar fetchAnnouncements time-range filtering #11

@truthixify

Description

@truthixify

Labels: Stellar Wave, stellar, feature, drips, help-wanted
Tier: M (2–4 days)
Type: feature

Context

fetchAnnouncements('stellar') today returns announcements across a probed ledger range starting max - 5000 if no cursor is provided. There's no way to say "only give me announcements from the last hour" or "everything since I last scanned." Every consumer ends up paginating from scratch.

Spectre's background scanner re-fetches the same window every 5 minutes. The Soroban RPC is expensive. We need incremental scan support.

Scope

Extend fetchAnnouncements (and fetchAnnouncementsStream from #09 if it lands) to accept:

type FetchOpts = {
  fromLedger?: number      // earliest ledger to include (inclusive)
  toLedger?: number        // latest ledger (exclusive); defaults to latest
  fromTimestamp?: Date     // convenience: convert to ledger using Horizon
  toTimestamp?: Date
  cursor?: string          // resume from a previous run
}

Behavior:

  • cursor takes precedence over fromLedger if both supplied.
  • fromTimestamp and fromLedger are mutually exclusive; error if both set.
  • Returned result includes a nextCursor field consumers can pass to the next call.
  • If the Soroban RPC's retention window has elapsed past fromLedger, throw a typed error RetentionExceededError with the actual oldest available ledger.

Acceptance criteria

  • Implementation in sdk/src/chains/stellar/announcements.ts.
  • Tests covering: explicit range, cursor resume, timestamp conversion, retention-exceeded error.
  • Spectre follow-up issue filed for using the cursor approach in the background scanner (this is the big win — eliminating duplicate fetches).
  • Docs updated with a "incremental scanning" example.

Why this matters

This single change cuts Spectre's Stellar RPC usage by ~50×. Five-minute scans of the last five minutes only, not the last five hours.

Resources

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programdripsFunded via Drips NetworkfeatureNew feature workhelp wantedExtra attention is neededstellarTouches Stellar / Soroban code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions