From: LLFourn Date: Sun, 25 Aug 2024 05:35:18 +0000 (+1000) Subject: chore(core)!: s/tx_graph::Update/TxUpdate/ X-Git-Tag: v1.0.0-beta.2~2^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/struct.CommandStringError.html?a=commitdiff_plain;h=a5d076f215cd91173f55bda0d1cc59b9dde75511;p=bdk chore(core)!: s/tx_graph::Update/TxUpdate/ 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`. --- diff --git a/crates/chain/src/indexed_tx_graph.rs b/crates/chain/src/indexed_tx_graph.rs index 73ae458f..ed2a1f0c 100644 --- a/crates/chain/src/indexed_tx_graph.rs +++ b/crates/chain/src/indexed_tx_graph.rs @@ -90,10 +90,10 @@ where /// Apply an `update` directly. /// - /// `update` is a [`tx_graph::Update`] and the resultant changes is returned as [`ChangeSet`]. + /// `update` is a [`tx_graph::TxUpdate`] and the resultant changes is returned as [`ChangeSet`]. #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] - pub fn apply_update(&mut self, update: tx_graph::Update) -> ChangeSet { + pub fn apply_update(&mut self, update: tx_graph::TxUpdate) -> ChangeSet { let tx_graph = self.graph.apply_update(update); let indexer = self.index_tx_graph_changeset(&tx_graph); ChangeSet { tx_graph, indexer } @@ -114,7 +114,7 @@ where /// set to the current time. pub fn apply_update_at( &mut self, - update: tx_graph::Update, + update: tx_graph::TxUpdate, seen_at: Option, ) -> ChangeSet { let tx_graph = self.graph.apply_update_at(update, seen_at); diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 085418fc..127b47cf 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -78,7 +78,7 @@ //! # let tx_b = tx_from_hex(RAW_TX_2); //! let mut graph: TxGraph = TxGraph::default(); //! -//! let mut update = tx_graph::Update::default(); +//! let mut update = tx_graph::TxUpdate::default(); //! update.txs.push(Arc::new(tx_a)); //! update.txs.push(Arc::new(tx_b)); //! @@ -98,7 +98,7 @@ use crate::{Anchor, Balance, ChainOracle, ChainPosition, FullTxOut, Merge}; use alloc::collections::vec_deque::VecDeque; use alloc::sync::Arc; use alloc::vec::Vec; -pub use bdk_core::tx_graph::Update; +pub use bdk_core::TxUpdate; use bitcoin::{Amount, OutPoint, ScriptBuf, SignedAmount, Transaction, TxOut, Txid}; use core::fmt::{self, Formatter}; use core::{ @@ -106,7 +106,7 @@ use core::{ ops::{Deref, RangeInclusive}, }; -impl From> for Update { +impl From> for TxUpdate { fn from(graph: TxGraph) -> Self { Self { txs: graph.full_txs().map(|tx_node| tx_node.tx).collect(), @@ -120,8 +120,8 @@ impl From> for Update { } } -impl From> for TxGraph { - fn from(update: Update) -> Self { +impl From> for TxGraph { + fn from(update: TxUpdate) -> Self { let mut graph = TxGraph::::default(); let _ = graph.apply_update_at(update, None); graph @@ -655,7 +655,7 @@ impl TxGraph { /// exist in `update` but not in `self`). #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] - pub fn apply_update(&mut self, update: Update) -> ChangeSet { + pub fn apply_update(&mut self, update: TxUpdate) -> ChangeSet { use std::time::*; let now = SystemTime::now() .duration_since(UNIX_EPOCH) @@ -676,7 +676,7 @@ impl TxGraph { /// /// Use [`apply_update`](TxGraph::apply_update) to have the `seen_at` value automatically set /// to the current time. - pub fn apply_update_at(&mut self, update: Update, seen_at: Option) -> ChangeSet { + pub fn apply_update_at(&mut self, update: TxUpdate, seen_at: Option) -> ChangeSet { let mut changeset = ChangeSet::::default(); let mut unanchored_txs = HashSet::::new(); for tx in update.txs { diff --git a/crates/chain/tests/test_tx_graph.rs b/crates/chain/tests/test_tx_graph.rs index 4ce6772b..a49c9e5f 100644 --- a/crates/chain/tests/test_tx_graph.rs +++ b/crates/chain/tests/test_tx_graph.rs @@ -88,7 +88,7 @@ fn insert_txouts() { // Make the update graph let update = { - let mut update = tx_graph::Update::default(); + let mut update = tx_graph::TxUpdate::default(); for (outpoint, txout) in &update_ops { // Insert partials transactions. update.txouts.insert(*outpoint, txout.clone()); @@ -1137,12 +1137,12 @@ fn call_map_anchors_with_non_deterministic_anchor() { ); } -/// Tests `From` impls for conversion between [`TxGraph`] and [`tx_graph::Update`]. +/// Tests `From` impls for conversion between [`TxGraph`] and [`tx_graph::TxUpdate`]. #[test] fn tx_graph_update_conversion() { - use tx_graph::Update; + use tx_graph::TxUpdate; - type TestCase = (&'static str, Update); + type TestCase = (&'static str, TxUpdate); fn make_tx(v: i32) -> Transaction { Transaction { @@ -1161,24 +1161,24 @@ fn tx_graph_update_conversion() { } let test_cases: &[TestCase] = &[ - ("empty_update", Update::default()), + ("empty_update", TxUpdate::default()), ( "single_tx", - Update { + TxUpdate { txs: vec![make_tx(0).into()], ..Default::default() }, ), ( "two_txs", - Update { + TxUpdate { txs: vec![make_tx(0).into(), make_tx(1).into()], ..Default::default() }, ), ( "with_floating_txouts", - Update { + TxUpdate { txs: vec![make_tx(0).into(), make_tx(1).into()], txouts: [ (OutPoint::new(h!("a"), 0), make_txout(0)), @@ -1191,7 +1191,7 @@ fn tx_graph_update_conversion() { ), ( "with_anchors", - Update { + TxUpdate { txs: vec![make_tx(0).into(), make_tx(1).into()], txouts: [ (OutPoint::new(h!("a"), 0), make_txout(0)), @@ -1209,7 +1209,7 @@ fn tx_graph_update_conversion() { ), ( "with_seen_ats", - Update { + TxUpdate { txs: vec![make_tx(0).into(), make_tx(1).into()], txouts: [ (OutPoint::new(h!("a"), 0), make_txout(0)), @@ -1230,7 +1230,7 @@ fn tx_graph_update_conversion() { for (test_name, update) in test_cases { let mut tx_graph = TxGraph::::default(); let _ = tx_graph.apply_update_at(update.clone(), None); - let update_from_tx_graph: Update = tx_graph.into(); + let update_from_tx_graph: TxUpdate = tx_graph.into(); assert_eq!( update diff --git a/crates/core/src/block_id.rs b/crates/core/src/block_id.rs new file mode 100644 index 00000000..2e64c9cb --- /dev/null +++ b/crates/core/src/block_id.rs @@ -0,0 +1,51 @@ +use bitcoin::{hashes::Hash, BlockHash}; + +/// A reference to a block in the canonical chain. +#[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +pub struct BlockId { + /// The height of the block. + pub height: u32, + /// The hash of the block. + pub hash: BlockHash, +} + +impl Default for BlockId { + fn default() -> Self { + Self { + height: Default::default(), + hash: BlockHash::all_zeros(), + } + } +} + +impl From<(u32, BlockHash)> for BlockId { + fn from((height, hash): (u32, BlockHash)) -> Self { + Self { height, hash } + } +} + +impl From for (u32, BlockHash) { + fn from(block_id: BlockId) -> Self { + (block_id.height, block_id.hash) + } +} + +impl From<(&u32, &BlockHash)> for BlockId { + fn from((height, hash): (&u32, &BlockHash)) -> Self { + Self { + height: *height, + hash: *hash, + } + } +} + +/// Represents the confirmation block and time of a transaction. +#[derive(Debug, Default, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +pub struct ConfirmationBlockTime { + /// The anchor block. + pub block_id: BlockId, + /// The confirmation time of the transaction being anchored. + pub confirmation_time: u64, +} diff --git a/crates/core/src/chain_data.rs b/crates/core/src/chain_data.rs deleted file mode 100644 index 2e64c9cb..00000000 --- a/crates/core/src/chain_data.rs +++ /dev/null @@ -1,51 +0,0 @@ -use bitcoin::{hashes::Hash, BlockHash}; - -/// A reference to a block in the canonical chain. -#[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -pub struct BlockId { - /// The height of the block. - pub height: u32, - /// The hash of the block. - pub hash: BlockHash, -} - -impl Default for BlockId { - fn default() -> Self { - Self { - height: Default::default(), - hash: BlockHash::all_zeros(), - } - } -} - -impl From<(u32, BlockHash)> for BlockId { - fn from((height, hash): (u32, BlockHash)) -> Self { - Self { height, hash } - } -} - -impl From for (u32, BlockHash) { - fn from(block_id: BlockId) -> Self { - (block_id.height, block_id.hash) - } -} - -impl From<(&u32, &BlockHash)> for BlockId { - fn from((height, hash): (&u32, &BlockHash)) -> Self { - Self { - height: *height, - hash: *hash, - } - } -} - -/// Represents the confirmation block and time of a transaction. -#[derive(Debug, Default, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -pub struct ConfirmationBlockTime { - /// The anchor block. - pub block_id: BlockId, - /// The confirmation time of the transaction being anchored. - pub confirmation_time: u64, -} diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 038bee62..aeb34dca 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -59,55 +59,13 @@ pub type Indexed = (u32, T); /// A tuple of keychain `K`, derivation index (`u32`) and a `T` associated with them. pub type KeychainIndexed = ((K, u32), T); -mod chain_data; -pub use chain_data::*; +mod block_id; +pub use block_id::*; mod checkpoint; pub use checkpoint::*; -pub mod spk_client; - -/// Core structures for [`TxGraph`]. -/// -/// [`TxGraph`]: https://docs.rs/bdk_chain/latest/bdk_chain/tx_graph/struct.TxGraph.html -pub mod tx_graph { - use crate::collections::{BTreeMap, BTreeSet, HashMap}; - use alloc::{sync::Arc, vec::Vec}; - use bitcoin::{OutPoint, Transaction, TxOut, Txid}; - - /// Data object used to update a [`TxGraph`]. - /// - /// [`TxGraph`]: https://docs.rs/bdk_chain/latest/bdk_chain/tx_graph/struct.TxGraph.html - #[derive(Debug, Clone)] - pub struct Update { - /// Full transactions. - pub txs: Vec>, - /// Floating txouts. - pub txouts: BTreeMap, - /// Transaction anchors. - pub anchors: BTreeSet<(A, Txid)>, - /// Seen at times for transactions. - pub seen_ats: HashMap, - } +mod tx_update; +pub use tx_update::*; - impl Default for Update { - fn default() -> Self { - Self { - txs: Default::default(), - txouts: Default::default(), - anchors: Default::default(), - seen_ats: Default::default(), - } - } - } - - impl Update { - /// Extend this update with `other`. - pub fn extend(&mut self, other: Update) { - self.txs.extend(other.txs); - self.txouts.extend(other.txouts); - self.anchors.extend(other.anchors); - self.seen_ats.extend(other.seen_ats); - } - } -} +pub mod spk_client; diff --git a/crates/core/src/spk_client.rs b/crates/core/src/spk_client.rs index e54849fb..1aceae5b 100644 --- a/crates/core/src/spk_client.rs +++ b/crates/core/src/spk_client.rs @@ -323,18 +323,16 @@ impl SyncRequest { #[must_use] #[derive(Debug)] pub struct SyncResult { - /// The update to apply to the receiving - /// [`TxGraph`](../../bdk_chain/tx_graph/struct.TxGraph.html). - pub graph_update: crate::tx_graph::Update, - /// The update to apply to the receiving - /// [`LocalChain`](../../bdk_chain/local_chain/struct.LocalChain.html). + /// Relevant transaction data discovered during the scan. + pub tx_update: crate::TxUpdate, + /// Changes to the chain discovered during the scan. pub chain_update: Option, } impl Default for SyncResult { fn default() -> Self { Self { - graph_update: Default::default(), + tx_update: Default::default(), chain_update: Default::default(), } } @@ -462,19 +460,19 @@ impl FullScanRequest { #[must_use] #[derive(Debug)] pub struct FullScanResult { - /// The update to apply to the receiving - /// [`LocalChain`](../../bdk_chain/local_chain/struct.LocalChain.html). - pub graph_update: crate::tx_graph::Update, - /// The update to apply to the receiving [`TxGraph`](../../bdk_chain/tx_graph/struct.TxGraph.html). - pub chain_update: Option, - /// Last active indices for the corresponding keychains (`K`). + /// Relevant transaction data discovered during the scan. + pub tx_update: crate::TxUpdate, + /// Last active indices for the corresponding keychains (`K`). An index is active if it had a + /// transaction associated with the script pubkey at that index. pub last_active_indices: BTreeMap, + /// Changes to the chain discovered during the scan. + pub chain_update: Option, } impl Default for FullScanResult { fn default() -> Self { Self { - graph_update: Default::default(), + tx_update: Default::default(), chain_update: Default::default(), last_active_indices: Default::default(), } diff --git a/crates/core/src/tx_update.rs b/crates/core/src/tx_update.rs new file mode 100644 index 00000000..a1ff75de --- /dev/null +++ b/crates/core/src/tx_update.rs @@ -0,0 +1,43 @@ +use crate::collections::{BTreeMap, BTreeSet, HashMap}; +use alloc::{sync::Arc, vec::Vec}; +use bitcoin::{OutPoint, Transaction, TxOut, Txid}; + +/// Data object used to communicate updates about relevant transactions from some chain data soruce +/// to the core model (usually a `bdk_chain::TxGraph`). +#[derive(Debug, Clone)] +pub struct TxUpdate { + /// Full transactions. These are transactions that were determined to be relevant to the wallet + /// given the request. + pub txs: Vec>, + /// Floating txouts. These are `TxOut`s that exist but the whole transaction wasn't included in + /// `txs` since only knowing about the output is important. These are often used to help determine + /// the fee of a wallet transaction. + pub txouts: BTreeMap, + /// Transaction anchors. Anchors tells us a position in the chain where a transaction was + /// confirmed. + pub anchors: BTreeSet<(A, Txid)>, + /// Seen at times for transactions. This records when a transaction was most recently seen in + /// the user's mempool for the sake of tie-breaking other conflicting transactions. + pub seen_ats: HashMap, +} + +impl Default for TxUpdate { + fn default() -> Self { + Self { + txs: Default::default(), + txouts: Default::default(), + anchors: Default::default(), + seen_ats: Default::default(), + } + } +} + +impl TxUpdate { + /// Extend this update with `other`. + pub fn extend(&mut self, other: TxUpdate) { + self.txs.extend(other.txs); + self.txouts.extend(other.txouts); + self.anchors.extend(other.anchors); + self.seen_ats.extend(other.seen_ats); + } +} diff --git a/crates/electrum/src/bdk_electrum_client.rs b/crates/electrum/src/bdk_electrum_client.rs index d78d7f64..a9806333 100644 --- a/crates/electrum/src/bdk_electrum_client.rs +++ b/crates/electrum/src/bdk_electrum_client.rs @@ -2,7 +2,7 @@ use bdk_core::{ bitcoin::{block::Header, BlockHash, OutPoint, ScriptBuf, Transaction, Txid}, collections::{BTreeMap, HashMap}, spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}, - tx_graph, BlockId, CheckPoint, ConfirmationBlockTime, + BlockId, CheckPoint, ConfirmationBlockTime, TxUpdate, }; use electrum_client::{ElectrumApi, Error, HeaderNotification}; use std::{ @@ -134,12 +134,12 @@ impl BdkElectrumClient { None => None, }; - let mut graph_update = tx_graph::Update::::default(); + let mut tx_update = TxUpdate::::default(); let mut last_active_indices = BTreeMap::::default(); for keychain in request.keychains() { let spks = request.iter_spks(keychain.clone()); if let Some(last_active_index) = - self.populate_with_spks(&mut graph_update, spks, stop_gap, batch_size)? + self.populate_with_spks(&mut tx_update, spks, stop_gap, batch_size)? { last_active_indices.insert(keychain, last_active_index); } @@ -147,20 +147,20 @@ impl BdkElectrumClient { // Fetch previous `TxOut`s for fee calculation if flag is enabled. if fetch_prev_txouts { - self.fetch_prev_txout(&mut graph_update)?; + self.fetch_prev_txout(&mut tx_update)?; } let chain_update = match tip_and_latest_blocks { Some((chain_tip, latest_blocks)) => Some(chain_update( chain_tip, &latest_blocks, - graph_update.anchors.iter().cloned(), + tx_update.anchors.iter().cloned(), )?), _ => None, }; Ok(FullScanResult { - graph_update, + tx_update, chain_update, last_active_indices, }) @@ -202,9 +202,9 @@ impl BdkElectrumClient { None => None, }; - let mut graph_update = tx_graph::Update::::default(); + let mut tx_update = TxUpdate::::default(); self.populate_with_spks( - &mut graph_update, + &mut tx_update, request .iter_spks() .enumerate() @@ -212,37 +212,37 @@ impl BdkElectrumClient { usize::MAX, batch_size, )?; - self.populate_with_txids(&mut graph_update, request.iter_txids())?; - self.populate_with_outpoints(&mut graph_update, request.iter_outpoints())?; + self.populate_with_txids(&mut tx_update, request.iter_txids())?; + self.populate_with_outpoints(&mut tx_update, request.iter_outpoints())?; // Fetch previous `TxOut`s for fee calculation if flag is enabled. if fetch_prev_txouts { - self.fetch_prev_txout(&mut graph_update)?; + self.fetch_prev_txout(&mut tx_update)?; } let chain_update = match tip_and_latest_blocks { Some((chain_tip, latest_blocks)) => Some(chain_update( chain_tip, &latest_blocks, - graph_update.anchors.iter().cloned(), + tx_update.anchors.iter().cloned(), )?), None => None, }; Ok(SyncResult { - graph_update, + tx_update, chain_update, }) } - /// Populate the `graph_update` with transactions/anchors associated with the given `spks`. + /// Populate the `tx_update` with transactions/anchors associated with the given `spks`. /// /// Transactions that contains an output with requested spk, or spends form an output with - /// requested spk will be added to `graph_update`. Anchors of the aforementioned transactions are + /// requested spk will be added to `tx_update`. Anchors of the aforementioned transactions are /// also included. fn populate_with_spks( &self, - graph_update: &mut tx_graph::Update, + tx_update: &mut TxUpdate, mut spks: impl Iterator, stop_gap: usize, batch_size: usize, @@ -275,20 +275,20 @@ impl BdkElectrumClient { } for tx_res in spk_history { - graph_update.txs.push(self.fetch_tx(tx_res.tx_hash)?); - self.validate_merkle_for_anchor(graph_update, tx_res.tx_hash, tx_res.height)?; + tx_update.txs.push(self.fetch_tx(tx_res.tx_hash)?); + self.validate_merkle_for_anchor(tx_update, tx_res.tx_hash, tx_res.height)?; } } } } - /// Populate the `graph_update` with associated transactions/anchors of `outpoints`. + /// Populate the `tx_update` with associated transactions/anchors of `outpoints`. /// /// Transactions in which the outpoint resides, and transactions that spend from the outpoint are /// included. Anchors of the aforementioned transactions are included. fn populate_with_outpoints( &self, - graph_update: &mut tx_graph::Update, + tx_update: &mut TxUpdate, outpoints: impl IntoIterator, ) -> Result<(), Error> { for outpoint in outpoints { @@ -311,8 +311,8 @@ impl BdkElectrumClient { if !has_residing && res.tx_hash == op_txid { has_residing = true; - graph_update.txs.push(Arc::clone(&op_tx)); - self.validate_merkle_for_anchor(graph_update, res.tx_hash, res.height)?; + tx_update.txs.push(Arc::clone(&op_tx)); + self.validate_merkle_for_anchor(tx_update, res.tx_hash, res.height)?; } if !has_spending && res.tx_hash != op_txid { @@ -325,18 +325,18 @@ impl BdkElectrumClient { if !has_spending { continue; } - graph_update.txs.push(Arc::clone(&res_tx)); - self.validate_merkle_for_anchor(graph_update, res.tx_hash, res.height)?; + tx_update.txs.push(Arc::clone(&res_tx)); + self.validate_merkle_for_anchor(tx_update, res.tx_hash, res.height)?; } } } Ok(()) } - /// Populate the `graph_update` with transactions/anchors of the provided `txids`. + /// Populate the `tx_update` with transactions/anchors of the provided `txids`. fn populate_with_txids( &self, - graph_update: &mut tx_graph::Update, + tx_update: &mut TxUpdate, txids: impl IntoIterator, ) -> Result<(), Error> { for txid in txids { @@ -360,10 +360,10 @@ impl BdkElectrumClient { .into_iter() .find(|r| r.tx_hash == txid) { - self.validate_merkle_for_anchor(graph_update, txid, r.height)?; + self.validate_merkle_for_anchor(tx_update, txid, r.height)?; } - graph_update.txs.push(tx); + tx_update.txs.push(tx); } Ok(()) } @@ -372,7 +372,7 @@ impl BdkElectrumClient { // An anchor is inserted if the transaction is validated to be in a confirmed block. fn validate_merkle_for_anchor( &self, - graph_update: &mut tx_graph::Update, + tx_update: &mut TxUpdate, txid: Txid, confirmation_height: i32, ) -> Result<(), Error> { @@ -399,7 +399,7 @@ impl BdkElectrumClient { } if is_confirmed_tx { - graph_update.anchors.insert(( + tx_update.anchors.insert(( ConfirmationBlockTime { confirmation_time: header.time as u64, block_id: BlockId { @@ -418,17 +418,17 @@ impl BdkElectrumClient { // which we do not have by default. This data is needed to calculate the transaction fee. fn fetch_prev_txout( &self, - graph_update: &mut tx_graph::Update, + tx_update: &mut TxUpdate, ) -> Result<(), Error> { let mut no_dup = HashSet::::new(); - for tx in &graph_update.txs { + for tx in &tx_update.txs { if no_dup.insert(tx.compute_txid()) { for vin in &tx.input { let outpoint = vin.previous_output; let vout = outpoint.vout; let prev_tx = self.fetch_tx(outpoint.txid)?; let txout = prev_tx.output[vout as usize].clone(); - let _ = graph_update.txouts.insert(outpoint, txout); + let _ = tx_update.txouts.insert(outpoint, txout); } } } diff --git a/crates/electrum/tests/test_electrum.rs b/crates/electrum/tests/test_electrum.rs index d5e4a159..5f032ba6 100644 --- a/crates/electrum/tests/test_electrum.rs +++ b/crates/electrum/tests/test_electrum.rs @@ -49,7 +49,7 @@ where .apply_update(chain_update) .map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?; } - let _ = graph.apply_update(update.graph_update.clone()); + let _ = graph.apply_update(update.tx_update.clone()); Ok(update) } @@ -120,15 +120,15 @@ pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { "update should not alter original checkpoint tip since we already started with all checkpoints", ); - let graph_update = sync_update.graph_update; + let tx_update = sync_update.tx_update; let updated_graph = { let mut graph = TxGraph::::default(); - let _ = graph.apply_update(graph_update.clone()); + let _ = graph.apply_update(tx_update.clone()); graph }; // Check to see if we have the floating txouts available from our two created transactions' // previous outputs in order to calculate transaction fees. - for tx in &graph_update.txs { + for tx in &tx_update.txs { // Retrieve the calculated fee from `TxGraph`, which will panic if we do not have the // floating txouts available from the transactions' previous outputs. let fee = updated_graph.calculate_fee(tx).expect("Fee must exist"); @@ -150,7 +150,7 @@ pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { } assert_eq!( - graph_update + tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -217,7 +217,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { .spks_for_keychain(0, spks.clone()); client.full_scan(request, 3, 1, false)? }; - assert!(full_scan_update.graph_update.txs.is_empty()); + assert!(full_scan_update.tx_update.txs.is_empty()); assert!(full_scan_update.last_active_indices.is_empty()); let full_scan_update = { let request = FullScanRequest::builder() @@ -227,7 +227,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { }; assert_eq!( full_scan_update - .graph_update + .tx_update .txs .first() .unwrap() @@ -259,7 +259,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { client.full_scan(request, 5, 1, false)? }; let txs: HashSet<_> = full_scan_update - .graph_update + .tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -274,7 +274,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { client.full_scan(request, 6, 1, false)? }; let txs: HashSet<_> = full_scan_update - .graph_update + .tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -478,7 +478,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> { )?; // Retain a snapshot of all anchors before reorg process. - let initial_anchors = update.graph_update.anchors.clone(); + let initial_anchors = update.tx_update.anchors.clone(); assert_eq!(initial_anchors.len(), REORG_COUNT); for i in 0..REORG_COUNT { let (anchor, txid) = initial_anchors.iter().nth(i).unwrap(); @@ -509,7 +509,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> { )?; // Check that no new anchors are added during current reorg. - assert!(initial_anchors.is_superset(&update.graph_update.anchors)); + assert!(initial_anchors.is_superset(&update.tx_update.anchors)); assert_eq!( get_balance(&recv_chain, &recv_graph)?, diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 041205c5..04e07c7c 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -3,7 +3,7 @@ use bdk_core::collections::{BTreeMap, BTreeSet, HashSet}; use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}; use bdk_core::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid}, - tx_graph, BlockId, CheckPoint, ConfirmationBlockTime, Indexed, + BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate, }; use futures::{stream::FuturesOrdered, TryStreamExt}; @@ -67,7 +67,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { None }; - let mut graph_update = tx_graph::Update::::default(); + let mut tx_update = TxUpdate::::default(); let mut inserted_txs = HashSet::::new(); let mut last_active_indices = BTreeMap::::new(); for keychain in keychains { @@ -80,7 +80,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { parallel_requests, ) .await?; - graph_update.extend(update); + tx_update.extend(update); if let Some(last_active_index) = last_active_index { last_active_indices.insert(keychain, last_active_index); } @@ -88,14 +88,14 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { let chain_update = match (chain_tip, latest_blocks) { (Some(chain_tip), Some(latest_blocks)) => { - Some(chain_update(self, &latest_blocks, &chain_tip, &graph_update.anchors).await?) + Some(chain_update(self, &latest_blocks, &chain_tip, &tx_update.anchors).await?) } _ => None, }; Ok(FullScanResult { chain_update, - graph_update, + tx_update, last_active_indices, }) } @@ -114,9 +114,9 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { None }; - let mut graph_update = tx_graph::Update::::default(); + let mut tx_update = TxUpdate::::default(); let mut inserted_txs = HashSet::::new(); - graph_update.extend( + tx_update.extend( fetch_txs_with_spks( self, &mut inserted_txs, @@ -125,7 +125,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { ) .await?, ); - graph_update.extend( + tx_update.extend( fetch_txs_with_txids( self, &mut inserted_txs, @@ -134,7 +134,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { ) .await?, ); - graph_update.extend( + tx_update.extend( fetch_txs_with_outpoints( self, &mut inserted_txs, @@ -146,14 +146,14 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { let chain_update = match (chain_tip, latest_blocks) { (Some(chain_tip), Some(latest_blocks)) => { - Some(chain_update(self, &latest_blocks, &chain_tip, &graph_update.anchors).await?) + Some(chain_update(self, &latest_blocks, &chain_tip, &tx_update.anchors).await?) } _ => None, }; Ok(SyncResult { chain_update, - graph_update, + tx_update, }) } } @@ -277,10 +277,10 @@ async fn fetch_txs_with_keychain_spks> + S mut keychain_spks: I, stop_gap: usize, parallel_requests: usize, -) -> Result<(tx_graph::Update, Option), Error> { +) -> Result<(TxUpdate, Option), Error> { type TxsOfSpkIndex = (u32, Vec); - let mut update = tx_graph::Update::::default(); + let mut update = TxUpdate::::default(); let mut last_index = Option::::None; let mut last_active_index = Option::::None; @@ -351,7 +351,7 @@ async fn fetch_txs_with_spks + Send>( inserted_txs: &mut HashSet, spks: I, parallel_requests: usize, -) -> Result, Error> +) -> Result, Error> where I::IntoIter: Send, { @@ -377,11 +377,11 @@ async fn fetch_txs_with_txids + Send>( inserted_txs: &mut HashSet, txids: I, parallel_requests: usize, -) -> Result, Error> +) -> Result, Error> where I::IntoIter: Send, { - let mut update = tx_graph::Update::::default(); + let mut update = TxUpdate::::default(); // Only fetch for non-inserted txs. let mut txids = txids .into_iter() @@ -426,12 +426,12 @@ async fn fetch_txs_with_outpoints + Send>( inserted_txs: &mut HashSet, outpoints: I, parallel_requests: usize, -) -> Result, Error> +) -> Result, Error> where I::IntoIter: Send, { let outpoints = outpoints.into_iter().collect::>(); - let mut update = tx_graph::Update::::default(); + let mut update = TxUpdate::::default(); // make sure txs exists in graph and tx statuses are updated // TODO: We should maintain a tx cache (like we do with Electrum). diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index d0744b4e..2552e6e8 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -2,7 +2,7 @@ use bdk_core::collections::{BTreeMap, BTreeSet, HashSet}; use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}; use bdk_core::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid}, - tx_graph, BlockId, CheckPoint, ConfirmationBlockTime, Indexed, + BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate, }; use esplora_client::{OutputStatus, Tx}; use std::thread::JoinHandle; @@ -62,7 +62,7 @@ impl EsploraExt for esplora_client::BlockingClient { None }; - let mut graph_update = tx_graph::Update::default(); + let mut tx_update = TxUpdate::default(); let mut inserted_txs = HashSet::::new(); let mut last_active_indices = BTreeMap::::new(); for keychain in request.keychains() { @@ -74,7 +74,7 @@ impl EsploraExt for esplora_client::BlockingClient { stop_gap, parallel_requests, )?; - graph_update.extend(update); + tx_update.extend(update); if let Some(last_active_index) = last_active_index { last_active_indices.insert(keychain, last_active_index); } @@ -85,14 +85,14 @@ impl EsploraExt for esplora_client::BlockingClient { self, &latest_blocks, &chain_tip, - &graph_update.anchors, + &tx_update.anchors, )?), _ => None, }; Ok(FullScanResult { chain_update, - graph_update, + tx_update, last_active_indices, }) } @@ -111,21 +111,21 @@ impl EsploraExt for esplora_client::BlockingClient { None }; - let mut graph_update = tx_graph::Update::::default(); + let mut tx_update = TxUpdate::::default(); let mut inserted_txs = HashSet::::new(); - graph_update.extend(fetch_txs_with_spks( + tx_update.extend(fetch_txs_with_spks( self, &mut inserted_txs, request.iter_spks(), parallel_requests, )?); - graph_update.extend(fetch_txs_with_txids( + tx_update.extend(fetch_txs_with_txids( self, &mut inserted_txs, request.iter_txids(), parallel_requests, )?); - graph_update.extend(fetch_txs_with_outpoints( + tx_update.extend(fetch_txs_with_outpoints( self, &mut inserted_txs, request.iter_outpoints(), @@ -137,14 +137,14 @@ impl EsploraExt for esplora_client::BlockingClient { self, &latest_blocks, &chain_tip, - &graph_update.anchors, + &tx_update.anchors, )?), _ => None, }; Ok(SyncResult { chain_update, - graph_update, + tx_update, }) } } @@ -254,10 +254,10 @@ fn fetch_txs_with_keychain_spks>>( mut keychain_spks: I, stop_gap: usize, parallel_requests: usize, -) -> Result<(tx_graph::Update, Option), Error> { +) -> Result<(TxUpdate, Option), Error> { type TxsOfSpkIndex = (u32, Vec); - let mut update = tx_graph::Update::::default(); + let mut update = TxUpdate::::default(); let mut last_index = Option::::None; let mut last_active_index = Option::::None; @@ -331,7 +331,7 @@ fn fetch_txs_with_spks>( inserted_txs: &mut HashSet, spks: I, parallel_requests: usize, -) -> Result, Error> { +) -> Result, Error> { fetch_txs_with_keychain_spks( client, inserted_txs, @@ -353,8 +353,8 @@ fn fetch_txs_with_txids>( inserted_txs: &mut HashSet, txids: I, parallel_requests: usize, -) -> Result, Error> { - let mut update = tx_graph::Update::::default(); +) -> Result, Error> { + let mut update = TxUpdate::::default(); // Only fetch for non-inserted txs. let mut txids = txids .into_iter() @@ -405,9 +405,9 @@ fn fetch_txs_with_outpoints>( inserted_txs: &mut HashSet, outpoints: I, parallel_requests: usize, -) -> Result, Error> { +) -> Result, Error> { let outpoints = outpoints.into_iter().collect::>(); - let mut update = tx_graph::Update::::default(); + let mut update = TxUpdate::::default(); // make sure txs exists in graph and tx statuses are updated // TODO: We should maintain a tx cache (like we do with Electrum). diff --git a/crates/esplora/src/lib.rs b/crates/esplora/src/lib.rs index 7aad133b..a166b6f9 100644 --- a/crates/esplora/src/lib.rs +++ b/crates/esplora/src/lib.rs @@ -21,7 +21,7 @@ //! [`esplora_client::AsyncClient`]. use bdk_core::bitcoin::{Amount, OutPoint, TxOut, Txid}; -use bdk_core::{tx_graph, BlockId, ConfirmationBlockTime}; +use bdk_core::{BlockId, ConfirmationBlockTime, TxUpdate}; use esplora_client::TxStatus; pub use esplora_client; @@ -37,7 +37,7 @@ mod async_ext; pub use async_ext::*; fn insert_anchor_from_status( - update: &mut tx_graph::Update, + update: &mut TxUpdate, txid: Txid, status: TxStatus, ) { @@ -59,7 +59,7 @@ fn insert_anchor_from_status( /// Inserts floating txouts into `tx_graph` using [`Vin`](esplora_client::api::Vin)s returned by /// Esplora. fn insert_prevouts( - update: &mut tx_graph::Update, + update: &mut TxUpdate, esplora_inputs: impl IntoIterator, ) { let prevouts = esplora_inputs diff --git a/crates/esplora/tests/async_ext.rs b/crates/esplora/tests/async_ext.rs index 7b0ef7fa..b535d2bf 100644 --- a/crates/esplora/tests/async_ext.rs +++ b/crates/esplora/tests/async_ext.rs @@ -78,15 +78,15 @@ pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { "update should not alter original checkpoint tip since we already started with all checkpoints", ); - let graph_update = sync_update.graph_update; + let tx_update = sync_update.tx_update; let updated_graph = { let mut graph = TxGraph::::default(); - let _ = graph.apply_update(graph_update.clone()); + let _ = graph.apply_update(tx_update.clone()); graph }; // Check to see if we have the floating txouts available from our two created transactions' // previous outputs in order to calculate transaction fees. - for tx in &graph_update.txs { + for tx in &tx_update.txs { // Retrieve the calculated fee from `TxGraph`, which will panic if we do not have the // floating txouts available from the transactions' previous outputs. let fee = updated_graph.calculate_fee(tx).expect("Fee must exist"); @@ -108,7 +108,7 @@ pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { } assert_eq!( - graph_update + tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -177,7 +177,7 @@ pub async fn test_async_update_tx_graph_stop_gap() -> anyhow::Result<()> { .spks_for_keychain(0, spks.clone()); client.full_scan(request, 3, 1).await? }; - assert!(full_scan_update.graph_update.txs.is_empty()); + assert!(full_scan_update.tx_update.txs.is_empty()); assert!(full_scan_update.last_active_indices.is_empty()); let full_scan_update = { let request = FullScanRequest::builder() @@ -187,7 +187,7 @@ pub async fn test_async_update_tx_graph_stop_gap() -> anyhow::Result<()> { }; assert_eq!( full_scan_update - .graph_update + .tx_update .txs .first() .unwrap() @@ -221,7 +221,7 @@ pub async fn test_async_update_tx_graph_stop_gap() -> anyhow::Result<()> { client.full_scan(request, 5, 1).await? }; let txs: HashSet<_> = full_scan_update - .graph_update + .tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -236,7 +236,7 @@ pub async fn test_async_update_tx_graph_stop_gap() -> anyhow::Result<()> { client.full_scan(request, 6, 1).await? }; let txs: HashSet<_> = full_scan_update - .graph_update + .tx_update .txs .iter() .map(|tx| tx.compute_txid()) diff --git a/crates/esplora/tests/blocking_ext.rs b/crates/esplora/tests/blocking_ext.rs index b3833b89..d4191ceb 100644 --- a/crates/esplora/tests/blocking_ext.rs +++ b/crates/esplora/tests/blocking_ext.rs @@ -78,15 +78,15 @@ pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { "update should not alter original checkpoint tip since we already started with all checkpoints", ); - let graph_update = sync_update.graph_update; + let tx_update = sync_update.tx_update; let updated_graph = { let mut graph = TxGraph::::default(); - let _ = graph.apply_update(graph_update.clone()); + let _ = graph.apply_update(tx_update.clone()); graph }; // Check to see if we have the floating txouts available from our two created transactions' // previous outputs in order to calculate transaction fees. - for tx in &graph_update.txs { + for tx in &tx_update.txs { // Retrieve the calculated fee from `TxGraph`, which will panic if we do not have the // floating txouts available from the transactions' previous outputs. let fee = updated_graph.calculate_fee(tx).expect("Fee must exist"); @@ -108,7 +108,7 @@ pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { } assert_eq!( - graph_update + tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -177,7 +177,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { .spks_for_keychain(0, spks.clone()); client.full_scan(request, 3, 1)? }; - assert!(full_scan_update.graph_update.txs.is_empty()); + assert!(full_scan_update.tx_update.txs.is_empty()); assert!(full_scan_update.last_active_indices.is_empty()); let full_scan_update = { let request = FullScanRequest::builder() @@ -187,7 +187,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { }; assert_eq!( full_scan_update - .graph_update + .tx_update .txs .first() .unwrap() @@ -221,7 +221,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { client.full_scan(request, 5, 1)? }; let txs: HashSet<_> = full_scan_update - .graph_update + .tx_update .txs .iter() .map(|tx| tx.compute_txid()) @@ -236,7 +236,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> { client.full_scan(request, 6, 1)? }; let txs: HashSet<_> = full_scan_update - .graph_update + .tx_update .txs .iter() .map(|tx| tx.compute_txid()) diff --git a/crates/wallet/src/wallet/export.rs b/crates/wallet/src/wallet/export.rs index 386d9d4e..ad5a6b2a 100644 --- a/crates/wallet/src/wallet/export.rs +++ b/crates/wallet/src/wallet/export.rs @@ -255,7 +255,7 @@ mod test { }; wallet .apply_update(Update { - graph: tx_graph::Update { + tx_update: tx_graph::TxUpdate { anchors: [(anchor, txid)].into_iter().collect(), ..Default::default() }, diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index 72c42ddf..5cad6bb8 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -33,7 +33,7 @@ use bdk_chain::{ FullScanRequest, FullScanRequestBuilder, FullScanResult, SyncRequest, SyncRequestBuilder, SyncResult, }, - tx_graph::{CanonicalTx, TxGraph, TxNode}, + tx_graph::{CanonicalTx, TxGraph, TxNode, TxUpdate}, BlockId, ChainPosition, ConfirmationBlockTime, ConfirmationTime, DescriptorExt, FullTxOut, Indexed, IndexedTxGraph, Merge, }; @@ -132,7 +132,7 @@ pub struct Update { pub last_active_indices: BTreeMap, /// Update for the wallet's internal [`TxGraph`]. - pub graph: chain::tx_graph::Update, + pub tx_update: TxUpdate, /// Update for the wallet's internal [`LocalChain`]. /// @@ -144,7 +144,7 @@ impl From> for Update { fn from(value: FullScanResult) -> Self { Self { last_active_indices: value.last_active_indices, - graph: value.graph_update, + tx_update: value.tx_update, chain: value.chain_update, } } @@ -154,7 +154,7 @@ impl From for Update { fn from(value: SyncResult) -> Self { Self { last_active_indices: BTreeMap::new(), - graph: value.graph_update, + tx_update: value.tx_update, chain: value.chain_update, } } @@ -2318,7 +2318,7 @@ impl Wallet { changeset.merge(index_changeset.into()); changeset.merge( self.indexed_graph - .apply_update_at(update.graph, seen_at) + .apply_update_at(update.tx_update, seen_at) .into(), ); self.stage.merge(changeset); @@ -2624,7 +2624,7 @@ macro_rules! doctest_wallet { block_id, }; let update = Update { - graph: tx_graph::Update { + tx_update: tx_graph::TxUpdate { anchors: [(anchor, txid)].into_iter().collect(), ..Default::default() }, diff --git a/crates/wallet/tests/common.rs b/crates/wallet/tests/common.rs index 561a9a5f..375d680d 100644 --- a/crates/wallet/tests/common.rs +++ b/crates/wallet/tests/common.rs @@ -220,7 +220,7 @@ pub fn insert_anchor_from_conf(wallet: &mut Wallet, txid: Txid, position: Confir wallet .apply_update(Update { - graph: tx_graph::Update { + tx_update: tx_graph::TxUpdate { anchors: [(anchor, txid)].into(), ..Default::default() }, diff --git a/crates/wallet/tests/wallet.rs b/crates/wallet/tests/wallet.rs index 24316165..2da25cd2 100644 --- a/crates/wallet/tests/wallet.rs +++ b/crates/wallet/tests/wallet.rs @@ -83,7 +83,7 @@ fn insert_seen_at(wallet: &mut Wallet, txid: Txid, seen_at: u64) { use bdk_wallet::Update; wallet .apply_update(Update { - graph: tx_graph::Update { + tx_update: tx_graph::TxUpdate { seen_ats: [(txid, seen_at)].into_iter().collect(), ..Default::default() }, diff --git a/example-crates/example_electrum/src/main.rs b/example-crates/example_electrum/src/main.rs index 21910cf6..9c705a3d 100644 --- a/example-crates/example_electrum/src/main.rs +++ b/example-crates/example_electrum/src/main.rs @@ -136,7 +136,7 @@ fn main() -> anyhow::Result<()> { .map(|tx_node| tx_node.tx), ); - let (chain_update, graph_update, keychain_update) = match electrum_cmd.clone() { + let (chain_update, tx_update, keychain_update) = match electrum_cmd.clone() { ElectrumCommands::Scan { stop_gap, scan_options, @@ -182,7 +182,7 @@ fn main() -> anyhow::Result<()> { .context("scanning the blockchain")?; ( res.chain_update, - res.graph_update, + res.tx_update, Some(res.last_active_indices), ) } @@ -251,7 +251,7 @@ fn main() -> anyhow::Result<()> { // drop lock on graph and chain drop((graph, chain)); - (res.chain_update, res.graph_update, None) + (res.chain_update, res.tx_update, None) } }; @@ -267,7 +267,7 @@ fn main() -> anyhow::Result<()> { 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)); + indexed_tx_graph_changeset.merge(graph.apply_update(tx_update)); ChangeSet { local_chain: chain_changeset, diff --git a/example-crates/example_esplora/src/main.rs b/example-crates/example_esplora/src/main.rs index 7a400587..cba86b86 100644 --- a/example-crates/example_esplora/src/main.rs +++ b/example-crates/example_esplora/src/main.rs @@ -164,7 +164,7 @@ fn main() -> anyhow::Result<()> { }; // The client scans keychain spks for transaction histories, stopping after `stop_gap` - // is reached. It returns a `TxGraph` update (`graph_update`) and a structure that + // is reached. It returns a `TxGraph` update (`tx_update`) and a structure that // represents the last active spk derivation indices of keychains // (`keychain_indices_update`). let update = client @@ -183,7 +183,7 @@ fn main() -> anyhow::Result<()> { let index_changeset = graph .index .reveal_to_target_multi(&update.last_active_indices); - let mut indexed_tx_graph_changeset = graph.apply_update(update.graph_update); + let mut indexed_tx_graph_changeset = graph.apply_update(update.tx_update); indexed_tx_graph_changeset.merge(index_changeset.into()); indexed_tx_graph_changeset }, @@ -269,7 +269,7 @@ fn main() -> anyhow::Result<()> { .lock() .unwrap() .apply_update(update.chain_update.expect("request has chain tip"))?, - graph.lock().unwrap().apply_update(update.graph_update), + graph.lock().unwrap().apply_update(update.tx_update), ) } };