Conversation
911085a to
c711102
Compare
|
Please keep track if any types or functions were modified other than just because things were moved around. Even though there are a lot of changes here if no types or logic were changed it shouldn't be too hard to review. |
92e442c to
6275e72
Compare
This is an initial version with `chain_data` types ported over. Types ported over include `BlockId`, `ConfirmationBlockTime`. The impls for `Anchor` and `AnchorFromBlockPosition` of these types are moved to where the traits are defined.
to be a separate function: `apply_changeset_to_checkpoint`.
Also add `CheckPoint::eq_ptr` which compares the internal pointers of two `CheckPoint`s. This is used as an optimisation when comparing two chains.
Also introduced extension trait for builder methods that take in a `KeychainTxOutIndex`. `Indexed<T>` and `KeychainIndexed<T>` are also moved to `bdk_core`.
`.populate_tx_cache` has been changed to take in a collection of `Arc<Transaction>`.
Helper methods have been changed to use concrete types (instead of `A: Anchor` generic) - since `Anchor` is still part of `bdk_chain`. Also fix esplora docs.
notmandatory
left a comment
There was a problem hiding this comment.
ACK dafb9aa
Great to see this PR only moves code around and decouple the chain clients from the chain module; plus some small docs and helper function cleanup. Your commits were concise and well documented which helped a lot with review.
I reran examples as a simple smoke test with no problems.
crates/core/src/lib.rs
Outdated
| /// Core structures for [`TxGraph`]. | ||
| /// | ||
| /// [`TxGraph`]: https://docs.rs/bdk_chain/latest/bdk_chain/tx_graph/struct.TxGraph.html | ||
| pub mod tx_graph { |
There was a problem hiding this comment.
We shouldn't mention TxGraph here too much. Now this thing lives here the Update can be used by any other software to process transaction updates. I'll push a commit.
crates/core/src/spk_client.rs
Outdated
| /// [`TxGraph`](../../bdk_chain/tx_graph/struct.TxGraph.html). | ||
| pub graph_update: crate::tx_graph::Update<A>, | ||
| /// The update to apply to the receiving | ||
| /// [`LocalChain`](../../bdk_chain/local_chain/struct.LocalChain.html). |
There was a problem hiding this comment.
Heh I guess this link is one way to do it but I think it's a mistake to mention LocalChain and TxGraph here. We are decoupling these things. What if we make a new chain type wouldn't a CheckPoint also be a valid update for it? (I'm pushing a commit).
| /// [`bdk_chain`]: ../bdk_chain/index.html | ||
| /// [`CalculateFeeError::MissingTxOut`]: ../bdk_chain/tx_graph/enum.CalculateFeeError.html#variant.MissingTxOut | ||
| /// [`Wallet.calculate_fee`]: ../bdk_wallet/struct.Wallet.html#method.calculate_fee | ||
| /// [`Wallet.calculate_fee_rate`]: ../bdk_wallet/struct.Wallet.html#method.calculate_fee_rate |
There was a problem hiding this comment.
⛏️ I'm against these kinds of doc links because they go stale without us noticing. Also they potentially link to incompatible versions. What if we change that method name etc?
It's enough to explain the concept.
Here are the remaining ones after a5d076f:
crates/core/src/spk_client.rs:113: /// This is used to update [`LocalChain`](../../bdk_chain/local_chain/struct.LocalChain.html).
crates/core/src/spk_client.rs:124: /// [`KeychainTxOutIndex`](../../bdk_chain/indexer/keychain_txout/struct.KeychainTxOutIndex.html).
crates/core/src/spk_client.rs:358: /// This is used to update [`LocalChain`](../../bdk_chain/local_chain/struct.LocalChain.html).
crates/electrum/src/bdk_electrum_client.rs:119: /// [`bdk_chain`]: ../bdk_chain/index.html
crates/electrum/src/bdk_electrum_client.rs:120: /// [`CalculateFeeError::MissingTxOut`]: ../bdk_chain/tx_graph/enum.CalculateFeeError.html#variant.MissingTxOut
crates/electrum/src/bdk_electrum_client.rs:121: /// [`Wallet.calculate_fee`]: ../bdk_wallet/struct.Wallet.html#method.calculate_fee
crates/electrum/src/bdk_electrum_client.rs:122: /// [`Wallet.calculate_fee_rate`]: ../bdk_wallet/struct.Wallet.html#method.calculate_fee_rate
crates/electrum/src/bdk_electrum_client.rs:188: /// [`bdk_chain`]: ../bdk_chain/index.html
crates/electrum/src/bdk_electrum_client.rs:189: /// [`CalculateFeeError::MissingTxOut`]: ../bdk_chain/tx_graph/enum.CalculateFeeError.html#variant.MissingTxOut
crates/electrum/src/bdk_electrum_client.rs:190: /// [`Wallet.calculate_fee`]: ../bdk_wallet/struct.Wallet.html#method.calculate_fee
crates/electrum/src/bdk_electrum_client.rs:191: /// [`Wallet.calculate_fee_rate`]: ../bdk_wallet/struct.Wallet.html#method.calculate_fee_rate
We shouldn't refer to `tx_graph` in `bdk_core`. TxGraph happens to consume `Update` but it doesn't conceptually own the definition of an update to transactions. I tried to also remove a lot of references to "graph" where they shouldn't be. "graph" is a very general kind of data structure so we should avoid referring to it where it's not relevant. `tx_update` is much better than `graph_update`.
LLFourn
left a comment
There was a problem hiding this comment.
I added a a5d076f:
We shouldn't refer to
tx_graphinbdk_core. TxGraph happens to consumeUpdatebut it doesn't conceptually own the definition of an update to transactions.
I tried to also remove a lot of references to "graph" where they shouldn't be. "graph" is a very general kind of data structure so we should avoid referring to it where it's not relevant.tx_updateis much better thangraph_update.
Self-ACK: a5d076f
evanlinjin
left a comment
There was a problem hiding this comment.
ACK a5d076f
TxUpdate makes sense. The doc changes make things clearer and easier to maintain.
| .full_txs() | ||
| .map(|tx_node| (tx_node.txid, tx_node.tx)); | ||
|
|
||
| pub fn populate_tx_cache(&self, txs: impl IntoIterator<Item = impl Into<Arc<Transaction>>>) { |
There was a problem hiding this comment.
Ideally this function could accept an iterator of (Txid, Arc<Transaction>) tuples
There was a problem hiding this comment.
This function is called at startup time so computing txid here is not really worth optimizing out.
Based on #1568
Closes #1543
Description
Introduce
bdk_corecrate. Move types over frombdk_chain. Chain sources (bdk_electrum,bdk_esploraandbdk_bitcoind_rpc) now only depend onbdk_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
bdk_corecrate which contains core types that were previously inbdk_chain. Including:BlockId,ConfirmationBlockTime,CheckPoint,CheckPointIter,tx_graph::Updateandspk_client-types.bdk_esplora,bdk_electrumandbdk_bitcoind_rpc) to only depend onbdk_core.Checklists
All Submissions:
cargo fmtandcargo clippybefore committing