-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce tx_graph::Update
and simplify TxGraph
update logic
#1568
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
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 <[email protected]>
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ccb8c79
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
Part of #1543
Closes #1550
Description
Instead of updating a
TxGraph
with anotherTxGraph
in.apply_update()
, we introducetx_graph::Update
.tx_graph::Update
is 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
TxGraph
by containing most of the update logic in.insert_{}
-esc methods..apply_update
and.apply_changeset
will call.insert_{}
methods internally and is greatly simplified. Thus, we also get rid of.determine_changeset
.We change
.apply_update
methods ofTxGraph
,IndexedTxGraph
andWallet
to implicitly setseen_at
to 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
TxGraph
and structures that build on top.Changelog notice
.apply_update
) ofTxGraph
to take in a simple data object (tx_graph::Update
)..apply_update
methods ofTxGraph
,IndexedTxGraph
andWallet
to implicitly set theseen_at
to the current timestamp for unconfirmed update transactions (this making them depend on the "std" cargo feature)..apply_update_at
which is the no-std version of.apply_update
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features: