Introduce tx_graph::Update and simplify TxGraph update logic#1568
Merged
LLFourn merged 6 commits intobitcoindevkit:masterfrom Aug 25, 2024
Merged
Introduce tx_graph::Update and simplify TxGraph update logic#1568LLFourn merged 6 commits intobitcoindevkit:masterfrom
tx_graph::Update and simplify TxGraph update logic#1568LLFourn merged 6 commits intobitcoindevkit:masterfrom
Conversation
Contain most of the insertion logic in `.insert_{}` methods, thus
simplifying `.apply_{}` methods. We can also get rid of
`.determine_changeset`.
2cabb5f to
8aeae45
Compare
LLFourn
reviewed
Aug 23, 2024
LLFourn
reviewed
Aug 23, 2024
LLFourn
reviewed
Aug 23, 2024
LLFourn
reviewed
Aug 23, 2024
f2d09e7 to
2897492
Compare
Instead of updating a `TxGraph` with a `TxGraph`, we introduce a dedicated data object (`tx_graph::Update`). This brings us closer to completing bitcoindevkit#1543. Co-authored-by: Wei Chen <wzc110@gmail.com>
Change `apply_update` to use the current timestamp as `seen_at` for unanchored transactions of the update. This makes `apply_update` only avaliable with the "std" feature. Introduce `apply_update_at` which includes an optional `seen_at` input. This is the no-std version of `apply_update`. Also update docs.
This is no longer needed as `TxGraph::apply_update` now automatically adds `seen_at` timestamps for unanchored transactions.
18048ba to
ccb8c79
Compare
3 tasks
notmandatory
approved these changes
Aug 23, 2024
Member
There was a problem hiding this comment.
ACK ccb8c79
Looks good and I can see how this will help decouple the blockchain clients from the wallet once tx_graph:Update is moved to a new crate.
I ran all the examples also as a little smoke test and they worked fine.
LLFourn
approved these changes
Aug 25, 2024
evanlinjin
added a commit
that referenced
this pull request
Aug 25, 2024
a5d076f chore(core)!: s/tx_graph::Update/TxUpdate/ (LLFourn) dafb9aa feat(bitcoind_rpc)!: depend on `bdk_core` instead of `bdk_chain` (志宇) fea8eed feat(esplora)!: depend on `bdk_core` instead of `bdk_chain` (志宇) 0d302f5 feat(electrum)!: depend on `bdk_core` instead of `bdk_chain` (志宇) ab0315d feat!: move `spk_client`s to `bdk_core` (志宇) bdea871 feat!: move `tx_graph::Update` to `bdk_core` (志宇) 77e31c7 feat!: move `CheckPoint` to `bdk_core` (志宇) a86c878 refactor(chain): change `CheckPoint::apply_changeset` (志宇) 6f7626a feat!: introduce `bdk_core` (志宇) Pull request description: Based on #1568 Closes #1543 ### Description Introduce `bdk_core` crate. Move types over from `bdk_chain`. Chain sources (`bdk_electrum`, `bdk_esplora` and `bdk_bitcoind_rpc`) now only depend on `bdk_core`. ### Notes to the reviewers Please review commit-by-commit. I've moved things over, but slight API changes were necessary (mentioned in the commit messages). ### Changelog notice * Add `bdk_core` crate which contains core types that were previously in `bdk_chain`. Including: `BlockId`, `ConfirmationBlockTime`, `CheckPoint`, `CheckPointIter`, `tx_graph::Update` and `spk_client`-types. * Change chain sources (`bdk_esplora`, `bdk_electrum` and `bdk_bitcoind_rpc`) to only depend on `bdk_core`. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: LLFourn: Self-ACK: a5d076f evanlinjin: ACK a5d076f Tree-SHA512: 13ecd0a2d2fc840b281977f07dc11fed27459f77c676af470134d2184db4a1fc352073ef82b1622e04fc60edb885e587ae8b9909c9bafb4ae63fcd51325d1cad
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.
Part of #1543
Closes #1550
Description
Instead of updating a
TxGraphwith anotherTxGraphin.apply_update(), we introducetx_graph::Update.tx_graph::Updateis a simple data object. This is the first step of #1543. This also makes it slightly less expensive to create an update.Additionally, we simplify the update logic of
TxGraphby containing most of the update logic in.insert_{}-esc methods..apply_updateand.apply_changesetwill call.insert_{}methods internally and is greatly simplified. Thus, we also get rid of.determine_changeset.We change
.apply_updatemethods ofTxGraph,IndexedTxGraphandWalletto implicitly setseen_atto the current timestamp for unconfirmed update transactions. This makes these methods only available when the"std"cargo feature is enabled. For a non-std environment, we introduce.apply_update_at(as shown below).During this process, I've fixed some tests that didn't make much sense.
Notes to the reviewers
There is a slight scope-creep, but they all address the update logic of
TxGraphand structures that build on top.Changelog notice
.apply_update) ofTxGraphto take in a simple data object (tx_graph::Update)..apply_updatemethods ofTxGraph,IndexedTxGraphandWalletto implicitly set theseen_atto the current timestamp for unconfirmed update transactions (this making them depend on the "std" cargo feature)..apply_update_atwhich is the no-std version of.apply_update.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: