Skip to content

Commit cb7a980

Browse files
committed
chore: Make clippy happy
1 parent 93657a0 commit cb7a980

File tree

18 files changed

+51
-74
lines changed

18 files changed

+51
-74
lines changed

crates/bitcoind_rpc/examples/filter_iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() -> anyhow::Result<()> {
7373
// apply relevant blocks
7474
if let Event::Block(EventInner { height, ref block }) = event {
7575
let _ = graph.apply_block_relevant(block, height);
76-
println!("Matched block {}", curr);
76+
println!("Matched block {curr}");
7777
}
7878
if curr % 1000 == 0 {
7979
let progress = (curr - start_height) as f32 / blocks_to_scan as f32;
@@ -107,7 +107,7 @@ fn main() -> anyhow::Result<()> {
107107

108108
let unused_spk = graph.index.reveal_next_spk("external").unwrap().0 .1;
109109
let unused_address = Address::from_script(&unused_spk, NETWORK)?;
110-
println!("Next external address: {}", unused_address);
110+
println!("Next external address: {unused_address}");
111111

112112
Ok(())
113113
}

crates/bitcoind_rpc/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,7 @@ mod test {
480480
for txid in &mempool_txids {
481481
assert!(
482482
emitter.expected_mempool_txids.contains(txid),
483-
"Expected txid {:?} missing",
484-
txid
483+
"Expected txid {txid:?} missing"
485484
);
486485
}
487486
}
@@ -502,15 +501,13 @@ mod test {
502501
for txid in confirmed_txids {
503502
assert!(
504503
!emitter.expected_mempool_txids.contains(&txid),
505-
"Expected txid {:?} should have been removed",
506-
txid
504+
"Expected txid {txid:?} should have been removed"
507505
);
508506
}
509507
for txid in &mempool_txids {
510508
assert!(
511509
emitter.expected_mempool_txids.contains(txid),
512-
"Expected txid {:?} missing",
513-
txid
510+
"Expected txid {txid:?} missing"
514511
);
515512
}
516513
}

crates/bitcoind_rpc/tests/test_emitter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
408408
confirmed: SEND_AMOUNT * (ADDITIONAL_COUNT - reorg_count) as u64,
409409
..Balance::default()
410410
},
411-
"reorg_count: {}",
412-
reorg_count,
411+
"reorg_count: {reorg_count}",
413412
);
414413
}
415414

crates/chain/src/indexer/keychain_txout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,15 +594,15 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
594594
let _inserted = self
595595
.inner
596596
.insert_spk((keychain.clone(), new_index), new_spk);
597-
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={:?}, lookahead={}, next_index={}", keychain, lookahead, next_index);
597+
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={keychain:?}, lookahead={lookahead}, next_index={next_index}");
598598
}
599599
} else {
600600
let spk_iter = SpkIterator::new_with_range(descriptor, next_index..stop_index);
601601
for (new_index, new_spk) in spk_iter {
602602
let _inserted = self
603603
.inner
604604
.insert_spk((keychain.clone(), new_index), new_spk);
605-
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={:?}, lookahead={}, next_index={}", keychain, lookahead, next_index);
605+
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={keychain:?}, lookahead={lookahead}, next_index={next_index}");
606606
}
607607
}
608608
}

crates/chain/src/rusqlite_impl.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,14 @@ pub const SCHEMAS_TABLE_NAME: &str = "bdk_schemas";
2222

2323
/// Initialize the schema table.
2424
fn init_schemas_table(db_tx: &Transaction) -> rusqlite::Result<()> {
25-
let sql = format!("CREATE TABLE IF NOT EXISTS {}( name TEXT PRIMARY KEY NOT NULL, version INTEGER NOT NULL ) STRICT", SCHEMAS_TABLE_NAME);
25+
let sql = format!("CREATE TABLE IF NOT EXISTS {SCHEMAS_TABLE_NAME}( name TEXT PRIMARY KEY NOT NULL, version INTEGER NOT NULL ) STRICT");
2626
db_tx.execute(&sql, ())?;
2727
Ok(())
2828
}
2929

3030
/// Get schema version of `schema_name`.
3131
fn schema_version(db_tx: &Transaction, schema_name: &str) -> rusqlite::Result<Option<u32>> {
32-
let sql = format!(
33-
"SELECT version FROM {} WHERE name=:name",
34-
SCHEMAS_TABLE_NAME
35-
);
32+
let sql = format!("SELECT version FROM {SCHEMAS_TABLE_NAME} WHERE name=:name");
3633
db_tx
3734
.query_row(&sql, named_params! { ":name": schema_name }, |row| {
3835
row.get::<_, u32>("version")
@@ -46,10 +43,7 @@ fn set_schema_version(
4643
schema_name: &str,
4744
schema_version: u32,
4845
) -> rusqlite::Result<()> {
49-
let sql = format!(
50-
"REPLACE INTO {}(name, version) VALUES(:name, :version)",
51-
SCHEMAS_TABLE_NAME,
52-
);
46+
let sql = format!("REPLACE INTO {SCHEMAS_TABLE_NAME}(name, version) VALUES(:name, :version)");
5347
db_tx.execute(
5448
&sql,
5549
named_params! { ":name": schema_name, ":version": schema_version },
@@ -799,7 +793,7 @@ mod test {
799793
":block_hash": Impl(anchor_block.hash),
800794
}) {
801795
Ok(updated) => assert_eq!(updated, 1),
802-
Err(err) => panic!("update failed: {}", err),
796+
Err(err) => panic!("update failed: {err}"),
803797
}
804798
}
805799
}

crates/chain/src/tx_graph.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ impl fmt::Display for CalculateFeeError {
281281
match self {
282282
CalculateFeeError::MissingTxOut(outpoints) => write!(
283283
f,
284-
"missing `TxOut` for one or more of the inputs of the tx: {:?}",
285-
outpoints
284+
"missing `TxOut` for one or more of the inputs of the tx: {outpoints:?}",
286285
),
287286
CalculateFeeError::NegativeFee(fee) => write!(
288287
f,
@@ -1119,12 +1118,7 @@ impl<A: Anchor> TxGraph<A> {
11191118
if !canonical_tx.tx_node.tx.is_coinbase() {
11201119
for txin in &canonical_tx.tx_node.tx.input {
11211120
let _res = canon_spends.insert(txin.previous_output, txid);
1122-
assert!(
1123-
_res.is_none(),
1124-
"tried to replace {:?} with {:?}",
1125-
_res,
1126-
txid
1127-
);
1121+
assert!(_res.is_none(), "tried to replace {_res:?} with {txid:?}",);
11281122
}
11291123
}
11301124
canon_txs.insert(txid, canonical_tx);

crates/chain/tests/test_indexed_tx_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn test_list_owned_txouts() {
281281
let chain_tip = local_chain
282282
.get(height)
283283
.map(|cp| cp.block_id())
284-
.unwrap_or_else(|| panic!("block must exist at {}", height));
284+
.unwrap_or_else(|| panic!("block must exist at {height}"));
285285
let txouts = graph
286286
.graph()
287287
.filter_chain_txouts(

crates/chain/tests/test_local_chain.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,9 @@ fn local_chain_insert_block() {
371371
assert_eq!(
372372
chain.insert_block(t.insert.into()),
373373
t.expected_result,
374-
"[{}] unexpected result when inserting block",
375-
i,
374+
"[{i}] unexpected result when inserting block",
376375
);
377-
assert_eq!(chain, t.expected_final, "[{}] unexpected final chain", i,);
376+
assert_eq!(chain, t.expected_final, "[{i}] unexpected final chain",);
378377
}
379378
}
380379

crates/chain/tests/test_tx_graph.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ fn test_calculate_fee_on_coinbase() {
598598
fn test_walk_ancestors() {
599599
let local_chain = LocalChain::from_blocks(
600600
(0..=20)
601-
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {}", ht).as_bytes())))
601+
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {ht}").as_bytes())))
602602
.collect(),
603603
)
604604
.expect("must contain genesis hash");
@@ -935,7 +935,7 @@ fn test_descendants_no_repeat() {
935935
fn test_chain_spends() {
936936
let local_chain = LocalChain::from_blocks(
937937
(0..=100)
938-
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {}", ht).as_bytes())))
938+
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {ht}").as_bytes())))
939939
.collect(),
940940
)
941941
.expect("must have genesis hash");
@@ -1453,23 +1453,19 @@ fn tx_graph_update_conversion() {
14531453
.iter()
14541454
.map(|tx| tx.compute_txid())
14551455
.collect::<HashSet<Txid>>(),
1456-
"{}: txs do not match",
1457-
test_name
1456+
"{test_name}: txs do not match"
14581457
);
14591458
assert_eq!(
14601459
update.txouts, update_from_tx_graph.txouts,
1461-
"{}: txouts do not match",
1462-
test_name
1460+
"{test_name}: txouts do not match"
14631461
);
14641462
assert_eq!(
14651463
update.anchors, update_from_tx_graph.anchors,
1466-
"{}: anchors do not match",
1467-
test_name
1464+
"{test_name}: anchors do not match"
14681465
);
14691466
assert_eq!(
14701467
update.seen_ats, update_from_tx_graph.seen_ats,
1471-
"{}: seen_ats do not match",
1472-
test_name
1468+
"{test_name}: seen_ats do not match"
14731469
);
14741470
}
14751471
}

crates/core/src/spk_client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ impl<I: core::fmt::Debug + core::any::Any> core::fmt::Display for SyncItem<'_, I
2626
match self {
2727
SyncItem::Spk(i, spk) => {
2828
if (i as &dyn core::any::Any).is::<()>() {
29-
write!(f, "script '{}'", spk)
29+
write!(f, "script '{spk}'")
3030
} else {
31-
write!(f, "script {:?} '{}'", i, spk)
31+
write!(f, "script {i:?} '{spk}'")
3232
}
3333
}
34-
SyncItem::Txid(txid) => write!(f, "txid '{}'", txid),
35-
SyncItem::OutPoint(op) => write!(f, "outpoint '{}'", op),
34+
SyncItem::Txid(txid) => write!(f, "txid '{txid}'"),
35+
SyncItem::OutPoint(op) => write!(f, "outpoint '{op}'"),
3636
}
3737
}
3838
}

0 commit comments

Comments
 (0)