Skip to content

Commit 8c90617

Browse files
committed
[bdk_chain_redesign] Make default anchor for TxGraph as ()
This allows us to use the old API with minimal changes. `TxGraph` methods have also been rearranged to allow for it.
1 parent 468701a commit 8c90617

3 files changed

Lines changed: 164 additions & 164 deletions

File tree

crates/bdk/src/wallet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<D> Wallet<D> {
524524
/// unconfirmed transactions last.
525525
pub fn transactions(
526526
&self,
527-
) -> impl DoubleEndedIterator<Item = (ConfirmationTime, TxInGraph<'_, Transaction, BlockId>)> + '_
527+
) -> impl DoubleEndedIterator<Item = (ConfirmationTime, TxInGraph<'_, Transaction, ()>)> + '_
528528
{
529529
self.keychain_tracker
530530
.chain_graph()

crates/chain/src/chain_graph.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use core::fmt::Debug;
2727
#[derive(Clone, Debug, PartialEq)]
2828
pub struct ChainGraph<P = TxHeight> {
2929
chain: SparseChain<P>,
30-
graph: TxGraph<BlockId>,
30+
graph: TxGraph,
3131
}
3232

3333
impl<P> Default for ChainGraph<P> {
@@ -45,8 +45,8 @@ impl<P> AsRef<SparseChain<P>> for ChainGraph<P> {
4545
}
4646
}
4747

48-
impl<P> AsRef<TxGraph<BlockId>> for ChainGraph<P> {
49-
fn as_ref(&self) -> &TxGraph<BlockId> {
48+
impl<P> AsRef<TxGraph> for ChainGraph<P> {
49+
fn as_ref(&self) -> &TxGraph {
5050
&self.graph
5151
}
5252
}
@@ -64,7 +64,7 @@ impl<P> ChainGraph<P> {
6464
}
6565

6666
/// Returns a reference to the internal [`TxGraph`].
67-
pub fn graph(&self) -> &TxGraph<BlockId> {
67+
pub fn graph(&self) -> &TxGraph {
6868
&self.graph
6969
}
7070
}
@@ -81,7 +81,7 @@ where
8181
/// transaction in `graph`.
8282
/// 2. The `chain` has two transactions that are allegedly in it, but they conflict in the `graph`
8383
/// (so could not possibly be in the same chain).
84-
pub fn new(chain: SparseChain<P>, graph: TxGraph<BlockId>) -> Result<Self, NewError<P>> {
84+
pub fn new(chain: SparseChain<P>, graph: TxGraph) -> Result<Self, NewError<P>> {
8585
let mut missing = HashSet::default();
8686
for (pos, txid) in chain.txids() {
8787
if let Some(graphed_tx) = graph.get_tx(*txid) {
@@ -212,7 +212,7 @@ where
212212
///
213213
/// This does not necessarily mean that it is *confirmed* in the blockchain; it might just be in
214214
/// the unconfirmed transaction list within the [`SparseChain`].
215-
pub fn get_tx_in_chain(&self, txid: Txid) -> Option<(&P, TxInGraph<'_, Transaction, BlockId>)> {
215+
pub fn get_tx_in_chain(&self, txid: Txid) -> Option<(&P, TxInGraph<'_, Transaction, ()>)> {
216216
let position = self.chain.tx_position(txid)?;
217217
let graphed_tx = self.graph.get_tx(txid).expect("must exist");
218218
Some((position, graphed_tx))
@@ -430,7 +430,7 @@ where
430430
/// in ascending order.
431431
pub fn transactions_in_chain(
432432
&self,
433-
) -> impl DoubleEndedIterator<Item = (&P, TxInGraph<'_, Transaction, BlockId>)> {
433+
) -> impl DoubleEndedIterator<Item = (&P, TxInGraph<'_, Transaction, ()>)> {
434434
self.chain
435435
.txids()
436436
.map(move |(pos, txid)| (pos, self.graph.get_tx(*txid).expect("must exist")))
@@ -469,7 +469,7 @@ where
469469
#[must_use]
470470
pub struct ChangeSet<P> {
471471
pub chain: sparse_chain::ChangeSet<P>,
472-
pub graph: tx_graph::Additions<BlockId>,
472+
pub graph: tx_graph::Additions<()>,
473473
}
474474

475475
impl<P> ChangeSet<P> {

0 commit comments

Comments
 (0)