Skip to content

Commit 3f9eec5

Browse files
committed
refactor(example): Reuse CanonicalView in filter iter example
1 parent 40790d0 commit 3f9eec5

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

crates/bitcoind_rpc/examples/filter_iter.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ fn main() -> anyhow::Result<()> {
6868

6969
println!("\ntook: {}s", start.elapsed().as_secs());
7070
println!("Local tip: {}", chain.tip().height());
71-
let unspent: Vec<_> = graph
72-
.canonical_view(&chain, chain.tip().block_id(), Default::default())
71+
72+
let canonical_view = graph.canonical_view(&chain, chain.tip().block_id(), Default::default());
73+
74+
let unspent: Vec<_> = canonical_view
7375
.filter_unspent_outpoints(graph.index.outpoints().clone())
7476
.collect();
7577
if !unspent.is_empty() {
@@ -80,14 +82,7 @@ fn main() -> anyhow::Result<()> {
8082
}
8183
}
8284

83-
for canon_tx in graph
84-
.canonical_view(
85-
&chain,
86-
chain.tip().block_id(),
87-
bdk_chain::CanonicalizationParams::default(),
88-
)
89-
.txs()
90-
{
85+
for canon_tx in canonical_view.txs() {
9186
if !canon_tx.pos.is_confirmed() {
9287
eprintln!("ERROR: canonical tx should be confirmed {}", canon_tx.txid);
9388
}

0 commit comments

Comments
 (0)