Skip to content

feat(esplora): add persistent tx cache to avoid re-fetching known txs - #2254

Open
GuTS805 wants to merge 1 commit into
bitcoindevkit:masterfrom
GuTS805:fix/esplora-tx-cache
Open

feat(esplora): add persistent tx cache to avoid re-fetching known txs#2254
GuTS805 wants to merge 1 commit into
bitcoindevkit:masterfrom
GuTS805:fix/esplora-tx-cache

Conversation

@GuTS805

@GuTS805 GuTS805 commented Aug 5, 2026

Copy link
Copy Markdown

Adds BdkEsploraClient wrapper (mirroring BdkElectrumClient) with an internal tx_cache and populate_tx_cache(). Cached txids now only trigger a lightweight get_tx_status() call instead of re-downloading the full transaction body via get_tx_info().

Fixes #2250

Description

bdk_esplora re-downloaded the full transaction body (get_tx_info) for every tracked txid on every sync, even when the tx was already fetched in a previous sync and only its confirmation status could have changed. bdk_electrum avoids this via BdkElectrumClient's persistent tx_cache; bdk_esplora had no equivalent (see the TODO in async_ext.rs:495 / blocking_ext.rs:454).

This PR adds BdkEsploraClient<C>, a wrapper around esplora_client::BlockingClient / AsyncClient that maintains a persistent in-memory tx_cache, mirroring BdkElectrumClient's pattern:

  • BdkEsploraClient::new(client) and populate_tx_cache() to pre-seed the cache from an existing TxGraph.
  • BdkEsploraClient::full_scan / sync inherent methods that use the cache.
  • For txids already in the cache, only a lightweight get_tx_status() call is made instead of re-downloading the full transaction via get_tx_info(). Only genuinely new/unseen txids trigger a full fetch.

The existing EsploraExt / EsploraAsyncExt traits on the raw esplora_client::BlockingClient / AsyncClient are unchanged, so this is fully backward compatible — the cache is opt-in via the new wrapper.

Notes to the reviewers

Couldn't run the bdk_testenv-based integration tests locally (Windows) — electrsd's build script requires std::os::unix, which doesn't exist on this platform. Confirmed this is a pre-existing limitation unrelated to this change (reproduces identically on master). Verified with cargo check --all-features and cargo clippy instead; CI should run the integration tests.

Changelog notice

Added: bdk_esplora: introduce BdkEsploraClient wrapper with a persistent transaction cache to avoid re-fetching already-downloaded transactions on sync.

Checklists

All Submissions:

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

Adds BdkEsploraClient wrapper (mirroring BdkElectrumClient) with an
internal tx_cache and populate_tx_cache(). Cached txids now only
trigger a lightweight get_tx_status() call instead of re-downloading
the full transaction body via get_tx_info().

Fixes bitcoindevkit#2250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

bdk_esplora: no transaction cache, re-fetches full tx body on every sync

1 participant