]> Untitled Git - bdk/commit
Implement linked-list `LocalChain` and update chain-src crates/examples
author志宇 <hello@evanlinjin.me>
Wed, 19 Jul 2023 09:42:52 +0000 (17:42 +0800)
committer志宇 <hello@evanlinjin.me>
Fri, 28 Jul 2023 03:30:16 +0000 (11:30 +0800)
commiteabeb6ccb169b32f7b7541c9dc6481693bdeeb8a
treea2fd56258baa00d12eab635e3e1115cf47558eb0
parentf4d2a76661d465dd0640d54470b95cc7b5ece979
Implement linked-list `LocalChain` and update chain-src crates/examples

This commit changes the `LocalChain` implementation to have blocks
stored as a linked-list. This allows the data-src thread to hold a
shared ref to a single checkpoint and have access to the whole history
of checkpoints without cloning or keeping a lock on `LocalChain`.

The APIs of `bdk::Wallet`, `esplora` and `electrum` are also updated to
reflect these changes. Note that the `esplora` crate is rewritten to
anchor txs in the confirmation block (using the esplora API's tx status
block_hash). This guarantees 100% consistency between anchor blocks and
their transactions (instead of anchoring txs to the latest tip).
`ExploraExt` now has separate methods for updating the `TxGraph` and
`LocalChain`.

A new method `TxGraph::missing_blocks` is introduced for finding
"floating anchors" of a `TxGraph` update (given a chain).

Additional changes:

* `test_local_chain.rs` is refactored to make test cases easier to
  write. Additional tests are also added.
* Examples are updated.
* Fix `tempfile` dev dependency of `bdk_file_store` to work with MSRV

Co-authored-by: LLFourn <lloyd.fourn@gmail.com>
18 files changed:
crates/bdk/src/wallet/mod.rs
crates/bdk/tests/wallet.rs
crates/chain/src/keychain.rs
crates/chain/src/local_chain.rs
crates/chain/src/tx_graph.rs
crates/chain/tests/common/mod.rs
crates/chain/tests/test_indexed_tx_graph.rs
crates/chain/tests/test_local_chain.rs
crates/chain/tests/test_tx_graph.rs
crates/electrum/src/electrum_ext.rs
crates/electrum/src/lib.rs
crates/esplora/src/async_ext.rs
crates/esplora/src/blocking_ext.rs
crates/esplora/src/lib.rs
example-crates/example_electrum/src/main.rs
example-crates/wallet_electrum/src/main.rs
example-crates/wallet_esplora/src/main.rs
example-crates/wallet_esplora_async/src/main.rs