Skip to content

Use persistent Electrum subscriptions - #21

Open
StellarStoic wants to merge 1 commit into
mainfrom
fix/electrum-subscriptions
Open

StellarStoic wants to merge 1 commit into
mainfrom
fix/electrum-subscriptions

Conversation

@StellarStoic

Copy link
Copy Markdown
Owner

Summary

  • keep one reconnecting Electrum JSON-RPC session instead of opening a TCP connection for every request
  • subscribe to each watched script hash before requesting its history or balance
  • cache unchanged snapshots and refresh only after Electrs sends a subscription status change
  • wake the scanner immediately on activity while retaining the 30-second poll as a reconnection and safety fallback
  • automatically resubscribe and reconcile cached state after Electrs restarts

This removes the repeated get_balance/get_history called for unsubscribed scripthash warnings emitted by recent Electrs versions and substantially reduces idle local-node traffic for large xpub and bulk-address watches.

Verification

  • go test ./...
  • go vet ./...
  • go test -race ./internal/electrum ./internal/app
  • new fake-Electrum tests verify subscribe-before-query ordering, unchanged-snapshot caching, notification-driven refresh, and reconnect/resubscribe behavior
  • subscription tests passed 50 consecutive runs
  • production Dockerfile build passed

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