feat: stream transactions and progress during sync#2242
Conversation
Add .on_event() API with PartialUpdate and AnchorsResolved events, TxUpdate::drain_since() for safe incremental application, and wire emission into Electrum and Esplora backends. Addresses bitcoindevkit#2202.
|
This PR is addressing an issue that is now closed. The feature is already (albeit in a different form) available today. @ANAMASGARD your approach with PRs on the BDK repos is in my opinion somewhat misguided at the moment. Your PRs are coming in at a staggering rate, across all repos and languages. As a maintainer, to me this reads like someone who is just sending Claude into a GitHub org, scanning for open and easy issues, and just prompting AI sub-agents into one-shotting a bunch of our issues without thought or care for deep understanding. For context: bitcoindevkit/bdk-dart#116, bitcoindevkit/bdk-dart#115, bitcoindevkit/bdk-dart#116, bitcoindevkit/bdk-dart#114, bitcoindevkit/bdk-dart#113, bitcoindevkit/book-of-bdk#156, bitcoindevkit/bdk-jvm#69, bitcoindevkit/bdk_wallet#513, bitcoindevkit/bdk_wallet#512, #2241, #2238, #2242. We are always happy to see new contributors, but if I may suggest something that would increase your chance of success, it'd be to spend time on a single repo/language and take time to learn it well. Interact on the issues, and get some PRs in slow and steady. Good luck. |
Closes #2202
Description
Adds incremental sync progress and transaction streaming to Electrum and Esplora backends.
Wallets can register
.on_event()onSyncRequest/FullScanRequestto receive:PartialUpdate(TxUpdate)— newly discovered txs/metadata at fetch boundariesAnchorsResolved(TxUpdate)— anchor-only delta after Electrum resolves confirmation proofsItemStarted/SpkStarted— progress events (.inspect()is sugar over these)TxUpdate::drain_since()destructively moves data out of the working buffer at each emission boundary. When events consume everything,response.tx_updateis naturally empty — applying it at the end is a safe no-op (no double-apply footgun).Consumer contract:
Emission points:
AnchorsResolvedafterbatch_fetch_anchorsExisting
sync/full_scansignatures are unchanged (additive API).Notes to the reviewers
.inspect()now routes through.on_event()internally (single reporter path); progress-only users are unaffected unless they also call.on_event().emit_partial_updatesdefaults tofalse— draining only happens when.on_event()is used.PartialUpdateintentionally lack anchors untilAnchorsResolved; seesync_defers_anchors_until_resolvedtest.EmitPartialtrait on the concrete request (notdynacross.await) to satisfySend.Changelog notice
SyncRequestEvent,FullScanRequestEvent,FullScanProgress, andTxUpdateCursortypes.SyncRequestBuilder::on_event()andFullScanRequestBuilder::on_event().TxUpdate::drain_since()for incremental delta extraction.PartialUpdateevents during sync/full_scan when.on_event()is registered.Checklists
All Submissions:
New Features:
Bugfixes: