Skip to content

feat: replace TxPoller polling with SSE streaming#259

Draft
Evalir wants to merge 2 commits intomainfrom
evalir/eop/sse-tx-poller
Draft

feat: replace TxPoller polling with SSE streaming#259
Evalir wants to merge 2 commits intomainfrom
evalir/eop/sse-tx-poller

Conversation

@Evalir
Copy link
Copy Markdown
Member

@Evalir Evalir commented Apr 2, 2026

Summary

Replaces the 1s timer-based polling loop in TxPoller with SSE streaming for real-time transaction delivery from the tx-pool. The new task lifecycle:

  1. Startup: full paginated fetch of all transactions currently in the cache
  2. Steady state: SSE stream (/transactions/feed) pushes new transactions as they arrive β€” no more redundant refetches
  3. Block env change: full refetch to ensure consistency (covers any items the SSE stream may have missed)

On SSE disconnect or error, the poller reconnects with exponential backoff (1s initial, doubling up to 30s cap) and does a full refetch to cover the gap. Backoff resets on each successfully received transaction.

Changes

  • Cargo.toml: enable sse feature on init4-bin-base (transitively enables signet-tx-cache/sse)
  • src/tasks/cache/tx.rs: rewrite TxPoller β€” replace poll loop with full_fetch() + subscribe() + select! over SSE items and block env changes. Add reconnect() with exponential backoff. Remove poll_interval_ms, poll_duration(), Default impl.
  • src/tasks/cache/system.rs: pass block_env watch receiver to TxPoller::new()
  • tests/tx_poller_test.rs: update integration test to use TxCache directly (no more check_tx_cache() method)

BundlePoller is unchanged β€” the /bundles/feed server endpoint is not yet available.

Test plan

  • make clippy passes clean
  • make test β€” all 8 unit tests pass, integration tests correctly ignored
  • Manual test against tx-pool: verify SSE subscription log, real-time tx delivery, refetch on block env change, reconnect with backoff on disconnect

πŸ€– Generated with Claude Code

Evalir and others added 2 commits April 2, 2026 19:52
Switch TxPoller from 1s timer-based polling to SSE streaming for
real-time transaction delivery. The new lifecycle:
1. Full fetch of all transactions at startup
2. SSE stream for real-time new transaction delivery
3. Full refetch on each block environment change

Adds exponential backoff (1s-30s) on SSE reconnection to prevent
tight loops when the endpoint is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Expand tokio import for nightly rustfmt, remove unresolved
`CacheTask` rustdoc link.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant