feat(chain)!: Implement ConfirmationBlockTime
Both `bdk_electrum` and `bdk_esplora` now report the exact block that the transaction is in, which removes the need for having the old `ConfirmationTimeHeightAnchor` and `ConfirmationHeightAnchor`. This PR introduces a new, simpler anchor type that can be modified to support additional data in the future.
This commit is contained in:
@@ -16,7 +16,7 @@ use bdk_chain::{
|
||||
indexed_tx_graph,
|
||||
indexer::keychain_txout,
|
||||
local_chain::{self, LocalChain},
|
||||
ConfirmationTimeHeightAnchor, IndexedTxGraph, Merge,
|
||||
ConfirmationBlockTime, IndexedTxGraph, Merge,
|
||||
};
|
||||
use example_cli::{
|
||||
anyhow,
|
||||
@@ -38,7 +38,7 @@ const DB_COMMIT_DELAY: Duration = Duration::from_secs(60);
|
||||
|
||||
type ChangeSet = (
|
||||
local_chain::ChangeSet,
|
||||
indexed_tx_graph::ChangeSet<ConfirmationTimeHeightAnchor, keychain_txout::ChangeSet<Keychain>>,
|
||||
indexed_tx_graph::ChangeSet<ConfirmationBlockTime, keychain_txout::ChangeSet<Keychain>>,
|
||||
);
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -10,7 +10,7 @@ use bdk_chain::{
|
||||
indexer::keychain_txout,
|
||||
local_chain::{self, LocalChain},
|
||||
spk_client::{FullScanRequest, SyncRequest},
|
||||
ConfirmationHeightAnchor, Merge,
|
||||
ConfirmationBlockTime, Merge,
|
||||
};
|
||||
use bdk_electrum::{
|
||||
electrum_client::{self, Client, ElectrumApi},
|
||||
@@ -100,7 +100,7 @@ pub struct ScanOptions {
|
||||
|
||||
type ChangeSet = (
|
||||
local_chain::ChangeSet,
|
||||
indexed_tx_graph::ChangeSet<ConfirmationHeightAnchor, keychain_txout::ChangeSet<Keychain>>,
|
||||
indexed_tx_graph::ChangeSet<ConfirmationBlockTime, keychain_txout::ChangeSet<Keychain>>,
|
||||
);
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
@@ -338,17 +338,12 @@ fn main() -> anyhow::Result<()> {
|
||||
let chain_changeset = chain.apply_update(chain_update)?;
|
||||
|
||||
let mut indexed_tx_graph_changeset =
|
||||
indexed_tx_graph::ChangeSet::<ConfirmationHeightAnchor, _>::default();
|
||||
indexed_tx_graph::ChangeSet::<ConfirmationBlockTime, _>::default();
|
||||
if let Some(keychain_update) = keychain_update {
|
||||
let keychain_changeset = graph.index.reveal_to_target_multi(&keychain_update);
|
||||
indexed_tx_graph_changeset.merge(keychain_changeset.into());
|
||||
}
|
||||
indexed_tx_graph_changeset.merge(graph.apply_update(graph_update.map_anchors(|a| {
|
||||
ConfirmationHeightAnchor {
|
||||
confirmation_height: a.confirmation_height,
|
||||
anchor_block: a.anchor_block,
|
||||
}
|
||||
})));
|
||||
indexed_tx_graph_changeset.merge(graph.apply_update(graph_update));
|
||||
|
||||
(chain_changeset, indexed_tx_graph_changeset)
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ use bdk_chain::{
|
||||
indexer::keychain_txout,
|
||||
local_chain::{self, LocalChain},
|
||||
spk_client::{FullScanRequest, SyncRequest},
|
||||
ConfirmationTimeHeightAnchor, Merge,
|
||||
ConfirmationBlockTime, Merge,
|
||||
};
|
||||
|
||||
use bdk_esplora::{esplora_client, EsploraExt};
|
||||
@@ -26,7 +26,7 @@ const DB_PATH: &str = ".bdk_esplora_example.db";
|
||||
|
||||
type ChangeSet = (
|
||||
local_chain::ChangeSet,
|
||||
indexed_tx_graph::ChangeSet<ConfirmationTimeHeightAnchor, keychain_txout::ChangeSet<Keychain>>,
|
||||
indexed_tx_graph::ChangeSet<ConfirmationBlockTime, keychain_txout::ChangeSet<Keychain>>,
|
||||
);
|
||||
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user