feat(esplora)!: remove EsploraExt::update_local_chain
Previously, we would update the `TxGraph` and `KeychainTxOutIndex` first, then create a second update for `LocalChain`. This required locking the receiving structures 3 times (instead of twice, which is optimal). This PR eliminates this requirement by making use of the new `query` method of `CheckPoint`. Examples are also updated to use the new API.
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
//! [`TxGraph`]: bdk_chain::tx_graph::TxGraph
|
||||
//! [`example_esplora`]: https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_esplora
|
||||
|
||||
use bdk_chain::{BlockId, ConfirmationTimeHeightAnchor};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use bdk_chain::{local_chain, BlockId, ConfirmationTimeHeightAnchor, TxGraph};
|
||||
use esplora_client::TxStatus;
|
||||
|
||||
pub use esplora_client;
|
||||
@@ -48,3 +50,21 @@ fn anchor_from_status(status: &TxStatus) -> Option<ConfirmationTimeHeightAnchor>
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Update returns from a full scan.
|
||||
pub struct FullScanUpdate<K> {
|
||||
/// The update to apply to the receiving [`LocalChain`](local_chain::LocalChain).
|
||||
pub local_chain: local_chain::Update,
|
||||
/// The update to apply to the receiving [`TxGraph`].
|
||||
pub tx_graph: TxGraph<ConfirmationTimeHeightAnchor>,
|
||||
/// Last active indices for the corresponding keychains (`K`).
|
||||
pub last_active_indices: BTreeMap<K, u32>,
|
||||
}
|
||||
|
||||
/// Update returned from a sync.
|
||||
pub struct SyncUpdate {
|
||||
/// The update to apply to the receiving [`LocalChain`](local_chain::LocalChain).
|
||||
pub local_chain: local_chain::Update,
|
||||
/// The update to apply to the receiving [`TxGraph`].
|
||||
pub tx_graph: TxGraph<ConfirmationTimeHeightAnchor>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user