feat(esplora): add persistent tx cache to avoid re-fetching known txs - #2254
Open
GuTS805 wants to merge 1 commit into
Open
feat(esplora): add persistent tx cache to avoid re-fetching known txs#2254GuTS805 wants to merge 1 commit into
GuTS805 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
BdkEsploraClientwrapper (mirroringBdkElectrumClient) with an internaltx_cacheandpopulate_tx_cache(). Cached txids now only trigger a lightweightget_tx_status()call instead of re-downloading the full transaction body viaget_tx_info().Fixes #2250
Description
bdk_esplorare-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_electrumavoids this viaBdkElectrumClient's persistenttx_cache;bdk_esplorahad no equivalent (see theTODOinasync_ext.rs:495/blocking_ext.rs:454).This PR adds
BdkEsploraClient<C>, a wrapper aroundesplora_client::BlockingClient/AsyncClientthat maintains a persistent in-memorytx_cache, mirroringBdkElectrumClient's pattern:BdkEsploraClient::new(client)andpopulate_tx_cache()to pre-seed the cache from an existingTxGraph.BdkEsploraClient::full_scan/syncinherent methods that use the cache.get_tx_status()call is made instead of re-downloading the full transaction viaget_tx_info(). Only genuinely new/unseen txids trigger a full fetch.The existing
EsploraExt/EsploraAsyncExttraits on the rawesplora_client::BlockingClient/AsyncClientare 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 requiresstd::os::unix, which doesn't exist on this platform. Confirmed this is a pre-existing limitation unrelated to this change (reproduces identically onmaster). Verified withcargo check --all-featuresandcargo clippyinstead; CI should run the integration tests.Changelog notice
Added:
bdk_esplora: introduceBdkEsploraClientwrapper with a persistent transaction cache to avoid re-fetching already-downloaded transactions on sync.Checklists
All Submissions:
New Features:
Bugfixes: