Subscriptions
This document covers all subscription methods and filtering options available in ThorPulse.
Simple Subscriptions
Simple subscriptions connect directly to NATS topic patterns. They're easy to use but don't support server-side filtering.
Slots
// All slot updates
slots := client.SubscribeSlotsChannel(ctx)
// Confirmed slots only
slots := client.SubscribeSlotsConfirmedChannel(ctx)Topic patterns:
slots.>- All slot eventsslots.*.confirmed- Confirmed slots onlyslots.*.finalized- Finalized slots onlyslots.{slot_number}.{status}- Specific slot
Transactions
// All transactions (high volume!)
txs := client.SubscribeAllTransactionsChannel(ctx)
// By program
txs := client.SubscribeProgramChannel(ctx, "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8")
// By account
txs := client.SubscribeAccountTransactionsChannel(ctx, pubkey)Topic patterns:
txs.slot.>- All transactionstxs.program.{program_id}.>- By programtxs.account.{pubkey}.>- By accounttxs.sig.{signature}.{slot}- Specific transaction
Entries
Topic patterns:
entries.>- All entriesentries.{slot}.{index}- Specific entry
Accounts
Topic patterns:
accounts.>- All account updatesaccounts.pubkey.{pubkey}.{slot}- Specific accountaccounts.owner.{program}.{slot}- By owner program
SubscribeRequest (Yellowstone-Style)
SubscribeRequest enables server-side filtering, reducing bandwidth and latency. It's the recommended approach for production.
Basic Usage
Filter Types
Slot Filter
Transaction Filter
Vote
*bool
true=votes only, false=non-votes only
Failed
*bool
true=failed only, false=successful only
Signature
string
Filter for specific signature
AccountInclude
[]string
Include if ANY account present
AccountExclude
[]string
Exclude if ANY account present
AccountRequired
[]string
Require ALL accounts present
Account Filter
Datasize
Match exact account data size
Memcmp
Match bytes at offset
TokenAccountState
Only valid SPL token accounts
Lamports.Eq
Exact lamport balance
Lamports.Ne
Not equal to balance
Lamports.Lt
Less than balance
Lamports.Gt
Greater than balance
Entry Filter
Entries don't have filter options - you receive all entries or none.
Block Filter
Block Meta Filter
Block metadata is lighter than full blocks - contains slot, blockhash, parent, rewards summary.
Commitment Levels
Processed
Transaction processed by leader
Real-time display
Confirmed
Confirmed by supermajority
Trading, analytics
Finalized
Guaranteed irreversible
Settlement, accounting
Handling Updates
Go Handler Pattern
Rust Stream Pattern
Performance Considerations
Subscription Limits
Each tier has subscription limits:
Flash: 100 concurrent subscriptions
Thor: 250 concurrent subscriptions
Prime: Unlimited
Topic Selection
Start specific, widen if needed:
Buffer Sizing
For high-volume subscriptions:
Backpressure
If you can't keep up:
Common Patterns
DEX Trading
Token Monitoring
Wallet Tracking
Last updated