Labels: Stellar Wave, stellar, perf, feature, drips, help-wanted
Tier: M (2–4 days)
Type: perf / feature
Context
scanAnnouncements currently takes a full array of announcements as input. For Spectre agents that have been running for months, this array can grow into the hundreds of thousands. Loading it all into memory is wasteful and breaks the agent's TEE memory budget.
We want a streaming API that can scan as the announcement stream arrives, never holding more than a small window in memory.
Scope
Add a new export scanAnnouncementsStream (Stellar first; pattern repeated per chain later):
async function* scanAnnouncementsStream(
source: AsyncIterable<Announcement>,
viewingKey: ...,
spendingPubKey: ...,
spendingKey: ...,
): AsyncGenerator<MatchedAnnouncement> { ... }
It must:
- Process announcements one at a time from the async iterable source.
- Yield matches as they're found (not in a batched array at the end).
- Keep peak memory bounded by O(window) where window is configurable (default 64).
- Support cancellation — if the consumer breaks out of the for-await loop, the stream stops cleanly.
Source providers
In the same PR, ship one source provider for Stellar:
async function* fetchAnnouncementsStream(network: Network, opts?): AsyncIterable<Announcement>
This wraps the existing paginated fetchAnnouncements and yields per page. Together they let a consumer write:
for await (const match of scanAnnouncementsStream(fetchAnnouncementsStream('stellar'), v, K, m)) {
notify(match)
}
Acceptance criteria
Why this matters
The TEE has tight memory limits. Spectre's current Stellar scan path will hit them within ~6 months of real production usage. We need to fix this before mainnet, not after.
Files
sdk/src/chains/stellar/scan.ts
sdk/src/chains/stellar/announcements.ts
Labels:
Stellar Wave,stellar,perf,feature,drips,help-wantedTier: M (2–4 days)
Type: perf / feature
Context
scanAnnouncementscurrently takes a full array of announcements as input. For Spectre agents that have been running for months, this array can grow into the hundreds of thousands. Loading it all into memory is wasteful and breaks the agent's TEE memory budget.We want a streaming API that can scan as the announcement stream arrives, never holding more than a small window in memory.
Scope
Add a new export
scanAnnouncementsStream(Stellar first; pattern repeated per chain later):It must:
Source providers
In the same PR, ship one source provider for Stellar:
This wraps the existing paginated
fetchAnnouncementsand yields per page. Together they let a consumer write:Acceptance criteria
scanAnnouncementsbecomes a thin wrapper over the streaming version (or deprecated cleanly).Why this matters
The TEE has tight memory limits. Spectre's current Stellar scan path will hit them within ~6 months of real production usage. We need to fix this before mainnet, not after.
Files
sdk/src/chains/stellar/scan.tssdk/src/chains/stellar/announcements.ts