Skip to content

Commit 0ab5ef4

Browse files
committed
chore: apply rustfmt
1 parent cd2913b commit 0ab5ef4

File tree

18 files changed

+131
-114
lines changed

18 files changed

+131
-114
lines changed

crates/bitcoind_rpc/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! This crate is used for emitting blockchain data from the `bitcoind` RPC interface. It does not
22
//! use the wallet RPC API, so this crate can be used with wallet-disabled Bitcoin Core nodes.
33
//!
4-
//! [`Emitter`] is the main structure which sources blockchain data from [`bitcoincore_rpc::Client`].
4+
//! [`Emitter`] is the main structure which sources blockchain data from
5+
//! [`bitcoincore_rpc::Client`].
56
//!
67
//! To only get block updates (exclude mempool transactions), the caller can use
78
//! [`Emitter::next_block`] or/and [`Emitter::next_header`] until it returns `Ok(None)` (which means
@@ -153,8 +154,8 @@ pub struct BlockEvent<B> {
153154
/// The checkpoint of the new block.
154155
///
155156
/// A [`CheckPoint`] is a node of a linked list of [`BlockId`]s. This checkpoint is linked to
156-
/// all [`BlockId`]s originally passed in [`Emitter::new`] as well as emitted blocks since then.
157-
/// These blocks are guaranteed to be of the same chain.
157+
/// all [`BlockId`]s originally passed in [`Emitter::new`] as well as emitted blocks since
158+
/// then. These blocks are guaranteed to be of the same chain.
158159
///
159160
/// This is important as BDK structures require block-to-apply to be connected with another
160161
/// block in the original chain.

crates/chain/src/indexed_tx_graph.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ where
9595

9696
/// Apply an `update` directly.
9797
///
98-
/// `update` is a [`tx_graph::TxUpdate<A>`] and the resultant changes is returned as [`ChangeSet`].
98+
/// `update` is a [`tx_graph::TxUpdate<A>`] and the resultant changes is returned as
99+
/// [`ChangeSet`].
99100
pub fn apply_update(&mut self, update: tx_graph::TxUpdate<A>) -> ChangeSet<A, I::ChangeSet> {
100101
let tx_graph = self.graph.apply_update(update);
101102
let indexer = self.index_tx_graph_changeset(&tx_graph);
@@ -325,7 +326,9 @@ where
325326
{
326327
/// List txids that are expected to exist under the given spks.
327328
///
328-
/// This is used to fill [`SyncRequestBuilder::expected_spk_txids`](bdk_core::spk_client::SyncRequestBuilder::expected_spk_txids).
329+
/// This is used to fill
330+
/// [`SyncRequestBuilder::expected_spk_txids`](bdk_core::spk_client::SyncRequestBuilder::expected_spk_txids).
331+
///
329332
///
330333
/// The spk index range can be contrained with `range`.
331334
///

crates/chain/src/indexer/keychain_txout.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ pub const DEFAULT_LOOKAHEAD: u32 = 25;
7070
///
7171
/// # Change sets
7272
///
73-
/// Methods that can update the last revealed index or add keychains will return [`ChangeSet`] to report
74-
/// these changes. This should be persisted for future recovery.
73+
/// Methods that can update the last revealed index or add keychains will return [`ChangeSet`] to
74+
/// report these changes. This should be persisted for future recovery.
7575
///
7676
/// ## Synopsis
7777
///
@@ -569,8 +569,8 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
569569
.map(|((_, i), spk)| (*i, spk))
570570
}
571571

572-
/// Get the next derivation index for `keychain`. The next index is the index after the last revealed
573-
/// derivation index.
572+
/// Get the next derivation index for `keychain`. The next index is the index after the last
573+
/// revealed derivation index.
574574
///
575575
/// The second field in the returned tuple represents whether the next derivation index is new.
576576
/// There are two scenarios where the next derivation index is reused (not new):
@@ -708,8 +708,8 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
708708
/// This will derive and reveal a new script pubkey if no more unused script pubkeys exist.
709709
///
710710
/// If the descriptor has no wildcard and already has a used script pubkey or if a descriptor
711-
/// has used all scripts up to the derivation bounds, then the last derived script pubkey will be
712-
/// returned.
711+
/// has used all scripts up to the derivation bounds, then the last derived script pubkey will
712+
/// be returned.
713713
///
714714
/// Returns `None` if there are no script pubkeys that have been used and no new script pubkey
715715
/// could be revealed (see [`reveal_next_spk`] for when this happens).

crates/chain/src/indexer/spk_txout.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! [`SpkTxOutIndex`] is an index storing [`TxOut`]s that have a script pubkey that matches those in a list.
1+
//! [`SpkTxOutIndex`] is an index storing [`TxOut`]s that have a script pubkey that matches those in
2+
//! a list.
23
34
use core::ops::RangeBounds;
45

@@ -15,14 +16,14 @@ use bitcoin::{Amount, OutPoint, ScriptBuf, SignedAmount, Transaction, TxOut, Txi
1516
/// index will look at any txouts you pass in and store and index any txouts matching one of its
1617
/// script pubkeys.
1718
///
18-
/// Each script pubkey is associated with an application-defined index script index `I`, which must be
19-
/// [`Ord`]. Usually, this is used to associate the derivation index of the script pubkey or even a
20-
/// combination of `(keychain, derivation_index)`.
19+
/// Each script pubkey is associated with an application-defined index script index `I`, which must
20+
/// be [`Ord`]. Usually, this is used to associate the derivation index of the script pubkey or even
21+
/// a combination of `(keychain, derivation_index)`.
2122
///
2223
/// Note there is no harm in scanning transactions that disappear from the blockchain or were never
2324
/// in there in the first place. `SpkTxOutIndex` is intentionally *monotone* -- you cannot delete or
24-
/// modify txouts that have been indexed. To find out which txouts from the index are actually in the
25-
/// chain or unspent, you must use other sources of information like a [`TxGraph`].
25+
/// modify txouts that have been indexed. To find out which txouts from the index are actually in
26+
/// the chain or unspent, you must use other sources of information like a [`TxGraph`].
2627
///
2728
/// [`TxOut`]: bitcoin::TxOut
2829
/// [`insert_spk`]: Self::insert_spk
@@ -89,9 +90,10 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
8990
///
9091
/// Typically, this is used in two situations:
9192
///
92-
/// 1. After loading transaction data from the disk, you may scan over all the txouts to restore all
93-
/// your txouts.
94-
/// 2. When getting new data from the chain, you usually scan it before incorporating it into your chain state.
93+
/// 1. After loading transaction data from the disk, you may scan over all the txouts to restore
94+
/// all your txouts.
95+
/// 2. When getting new data from the chain, you usually scan it before incorporating it into
96+
/// your chain state.
9597
pub fn scan(&mut self, tx: &Transaction) -> BTreeSet<I> {
9698
let mut scanned_indices = BTreeSet::new();
9799
let txid = tx.compute_txid();
@@ -191,7 +193,8 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
191193
&self.spks
192194
}
193195

194-
/// Adds a script pubkey to scan for. Returns `false` and does nothing if spk already exists in the map
196+
/// Adds a script pubkey to scan for. Returns `false` and does nothing if spk already exists in
197+
/// the map
195198
///
196199
/// the index will look for outputs spending to this spk whenever it scans new data.
197200
pub fn insert_spk(&mut self, index: I, spk: ScriptBuf) -> bool {
@@ -243,14 +246,14 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
243246
!self.unused.contains(index)
244247
}
245248

246-
/// Marks the script pubkey at `index` as used even though it hasn't seen an output spending to it.
247-
/// This only affects when the `index` had already been added to `self` and was unused.
249+
/// Marks the script pubkey at `index` as used even though it hasn't seen an output spending to
250+
/// it. This only affects when the `index` had already been added to `self` and was unused.
248251
///
249252
/// Returns whether the `index` was initially present as `unused`.
250253
///
251254
/// This is useful when you want to reserve a script pubkey for something but don't want to add
252-
/// the transaction output using it to the index yet. Other callers will consider the `index` used
253-
/// until you call [`unmark_used`].
255+
/// the transaction output using it to the index yet. Other callers will consider the `index`
256+
/// used until you call [`unmark_used`].
254257
///
255258
/// [`unmark_used`]: Self::unmark_used
256259
pub fn mark_used(&mut self, index: &I) -> bool {
@@ -326,8 +329,8 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
326329
/// matches one of our script pubkeys.
327330
///
328331
/// It is easily possible to misuse this method and get false negatives by calling it before you
329-
/// have scanned the `TxOut`s the transaction is spending. For example, if you want to filter out
330-
/// all the transactions in a block that are irrelevant, you **must first scan all the
332+
/// have scanned the `TxOut`s the transaction is spending. For example, if you want to filter
333+
/// out all the transactions in a block that are irrelevant, you **must first scan all the
331334
/// transactions in the block** and only then use this method.
332335
pub fn is_relevant(&self, tx: &Transaction) -> bool {
333336
let input_matches = tx

crates/chain/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
//! Our design goals for these mechanisms are:
1010
//!
1111
//! 1. Data source agnostic -- nothing in `bdk_chain` cares about where you get data from or whether
12-
//! you do it synchronously or asynchronously. If you know a fact about the blockchain, you can just
13-
//! tell `bdk_chain`'s APIs about it, and that information will be integrated, if it can be done
14-
//! consistently.
15-
//! 2. Data persistence agnostic -- `bdk_chain` does not care where you cache on-chain data, what you
16-
//! cache or how you retrieve it from persistent storage.
12+
//! you do it synchronously or asynchronously. If you know a fact about the blockchain, you can
13+
//! just tell `bdk_chain`'s APIs about it, and that information will be integrated, if it can be
14+
//! done consistently.
15+
//! 2. Data persistence agnostic -- `bdk_chain` does not care where you cache on-chain data, what
16+
//! you cache or how you retrieve it from persistent storage.
1717
//!
1818
//! [Bitcoin Dev Kit]: https://bitcoindevkit.org/
1919

crates/chain/src/local_chain.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ impl LocalChain {
178178
Ok(changeset)
179179
}
180180

181-
/// Update the chain with a given [`Header`] at `height` which you claim is connected to a existing block in the chain.
181+
/// Update the chain with a given [`Header`] at `height` which you claim is connected to a
182+
/// existing block in the chain.
182183
///
183184
/// This is useful when you have a block header that you want to record as part of the chain but
184185
/// don't necessarily know that the `prev_blockhash` is in the chain.
@@ -410,8 +411,8 @@ impl LocalChain {
410411
pub struct ChangeSet {
411412
/// Changes to the [`LocalChain`] blocks.
412413
///
413-
/// The key represents the block height, and the value either represents added a new [`CheckPoint`]
414-
/// (if [`Some`]), or removing a [`CheckPoint`] (if [`None`]).
414+
/// The key represents the block height, and the value either represents added a new
415+
/// [`CheckPoint`] (if [`Some`]), or removing a [`CheckPoint`] (if [`None`]).
415416
pub blocks: BTreeMap<u32, Option<BlockHash>>,
416417
}
417418

@@ -605,9 +606,10 @@ fn merge_chains(
605606
if o.hash() == u.hash() {
606607
// We have found our point of agreement 🎉 -- we require that the previous (i.e.
607608
// higher because we are iterating backwards) block in the original chain was
608-
// invalidated (if it exists). This ensures that there is an unambiguous point of
609-
// connection to the original chain from the update chain (i.e. we know the
610-
// precisely which original blocks are invalid).
609+
// invalidated (if it exists). This ensures that there is an unambiguous point
610+
// of connection to the original chain from the update chain
611+
// (i.e. we know the precisely which original blocks are
612+
// invalid).
611613
if !prev_orig_was_invalidated && !point_of_agreement_found {
612614
if let (Some(prev_orig), Some(_prev_update)) = (&prev_orig, &prev_update) {
613615
return Err(CannotConnectError {

crates/chain/src/spk_iter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub const BIP32_MAX_INDEX: u32 = (1 << 31) - 1;
1111
/// An iterator for derived script pubkeys.
1212
///
1313
/// [`SpkIterator`] is an implementation of the [`Iterator`] trait which possesses its own `next()`
14-
/// and `nth()` functions, both of which circumvent the unnecessary intermediate derivations required
15-
/// when using their default implementations.
14+
/// and `nth()` functions, both of which circumvent the unnecessary intermediate derivations
15+
/// required when using their default implementations.
1616
///
1717
/// ## Examples
1818
///
@@ -101,8 +101,8 @@ where
101101
type Item = Indexed<ScriptBuf>;
102102

103103
fn next(&mut self) -> Option<Self::Item> {
104-
// For non-wildcard descriptors, we expect the first element to be Some((0, spk)), then None after.
105-
// For wildcard descriptors, we expect it to keep iterating until exhausted.
104+
// For non-wildcard descriptors, we expect the first element to be Some((0, spk)), then None
105+
// after. For wildcard descriptors, we expect it to keep iterating until exhausted.
106106
if self.next_index >= self.end {
107107
return None;
108108
}

crates/chain/src/tx_graph.rs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
//!
2424
//! * [`list_canonical_txs`](TxGraph::list_canonical_txs) lists canonical transactions.
2525
//! * [`filter_chain_txouts`](TxGraph::filter_chain_txouts) filters out canonical outputs from a
26-
//! list of outpoints.
26+
//! list of outpoints.
2727
//! * [`filter_chain_unspents`](TxGraph::filter_chain_unspents) filters out canonical unspent
28-
//! outputs from a list of outpoints.
28+
//! outputs from a list of outpoints.
2929
//! * [`balance`](TxGraph::balance) gets the total sum of unspent outputs filtered from a list of
30-
//! outpoints.
30+
//! outpoints.
3131
//! * [`canonical_iter`](TxGraph::canonical_iter) returns the [`CanonicalIter`] which contains all
32-
//! of the canonicalization logic.
32+
//! of the canonicalization logic.
3333
//!
3434
//! All these methods require a `chain` and `chain_tip` argument. The `chain` must be a
3535
//! [`ChainOracle`] implementation (such as [`LocalChain`](crate::local_chain::LocalChain)) which
@@ -39,17 +39,17 @@
3939
//! transactions have precedence over others:
4040
//!
4141
//! * [`Anchor`] - This bit of data represents that a transaction is anchored in a given block. If
42-
//! the transaction is anchored in chain of `chain_tip`, or is an ancestor of a transaction
43-
//! anchored in chain of `chain_tip`, then the transaction must be canonical.
42+
//! the transaction is anchored in chain of `chain_tip`, or is an ancestor of a transaction
43+
//! anchored in chain of `chain_tip`, then the transaction must be canonical.
4444
//! * `last_seen` - This is the timestamp of when a transaction is last-seen in the mempool. This
45-
//! value is updated by [`insert_seen_at`](TxGraph::insert_seen_at) and
46-
//! [`apply_update`](TxGraph::apply_update). Transactions that are seen later have higher
47-
//! priority than those that are seen earlier. `last_seen` values are transitive. This means
48-
//! that the actual `last_seen` value of a transaction is the max of all the `last_seen` values
49-
//! from it's descendants.
45+
//! value is updated by [`insert_seen_at`](TxGraph::insert_seen_at) and
46+
//! [`apply_update`](TxGraph::apply_update). Transactions that are seen later have higher priority
47+
//! than those that are seen earlier. `last_seen` values are transitive. This means that the
48+
//! actual `last_seen` value of a transaction is the max of all the `last_seen` values from it's
49+
//! descendants.
5050
//! * `last_evicted` - This is the timestamp of when a transaction last went missing from the
51-
//! mempool. If this value is equal to or higher than the transaction's `last_seen` value, then
52-
//! it will not be considered canonical.
51+
//! mempool. If this value is equal to or higher than the transaction's `last_seen` value, then it
52+
//! will not be considered canonical.
5353
//!
5454
//! # Graph traversal
5555
//!
@@ -392,13 +392,13 @@ impl<A> TxGraph<A> {
392392
})
393393
}
394394

395-
/// Calculates the fee of a given transaction. Returns [`Amount::ZERO`] if `tx` is a coinbase transaction.
396-
/// Returns `OK(_)` if we have all the [`TxOut`]s being spent by `tx` in the graph (either as
397-
/// the full transactions or individual txouts).
395+
/// Calculates the fee of a given transaction. Returns [`Amount::ZERO`] if `tx` is a coinbase
396+
/// transaction. Returns `OK(_)` if we have all the [`TxOut`]s being spent by `tx` in the
397+
/// graph (either as the full transactions or individual txouts).
398398
///
399399
/// To calculate the fee for a [`Transaction`] that depends on foreign [`TxOut`] values you must
400-
/// first manually insert the foreign TxOuts into the tx graph using the [`insert_txout`] function.
401-
/// Only insert TxOuts you trust the values for!
400+
/// first manually insert the foreign TxOuts into the tx graph using the [`insert_txout`]
401+
/// function. Only insert TxOuts you trust the values for!
402402
///
403403
/// Note `tx` does not have to be in the graph for this to work.
404404
///
@@ -471,7 +471,7 @@ impl<A: Clone + Ord> TxGraph<A> {
471471
/// The supplied closure takes in two inputs `(depth, ancestor_tx)`:
472472
///
473473
/// * `depth` is the distance between the starting `Transaction` and the `ancestor_tx`. I.e., if
474-
/// the `Transaction` is spending an output of the `ancestor_tx` then `depth` will be 1.
474+
/// the `Transaction` is spending an output of the `ancestor_tx` then `depth` will be 1.
475475
/// * `ancestor_tx` is the `Transaction`'s ancestor which we are considering to walk.
476476
///
477477
/// The supplied closure returns an `Option<T>`, allowing the caller to map each `Transaction`
@@ -488,8 +488,8 @@ impl<A: Clone + Ord> TxGraph<A> {
488488
///
489489
/// The supplied closure takes in two inputs `(depth, descendant_txid)`:
490490
///
491-
/// * `depth` is the distance between the starting `txid` and the `descendant_txid`. I.e., if the
492-
/// descendant is spending an output of the starting `txid` then `depth` will be 1.
491+
/// * `depth` is the distance between the starting `txid` and the `descendant_txid`. I.e., if
492+
/// the descendant is spending an output of the starting `txid` then `depth` will be 1.
493493
/// * `descendant_txid` is the descendant's txid which we are considering to walk.
494494
///
495495
/// The supplied closure returns an `Option<T>`, allowing the caller to map each node it visits
@@ -779,8 +779,8 @@ impl<A: Anchor> TxGraph<A> {
779779

780780
/// Extends this graph with the given `update`.
781781
///
782-
/// The returned [`ChangeSet`] is the set difference between `update` and `self` (transactions that
783-
/// exist in `update` but not in `self`).
782+
/// The returned [`ChangeSet`] is the set difference between `update` and `self` (transactions
783+
/// that exist in `update` but not in `self`).
784784
pub fn apply_update(&mut self, update: TxUpdate<A>) -> ChangeSet<A> {
785785
let mut changeset = ChangeSet::<A>::default();
786786
for tx in update.txs {
@@ -1158,7 +1158,9 @@ impl<A: Anchor> TxGraph<A> {
11581158

11591159
/// List txids that are expected to exist under the given spks.
11601160
///
1161-
/// This is used to fill [`SyncRequestBuilder::expected_spk_txids`](bdk_core::spk_client::SyncRequestBuilder::expected_spk_txids).
1161+
/// This is used to fill
1162+
/// [`SyncRequestBuilder::expected_spk_txids`](bdk_core::spk_client::SyncRequestBuilder::expected_spk_txids).
1163+
///
11621164
///
11631165
/// The spk index range can be constrained with `range`.
11641166
///

0 commit comments

Comments
 (0)