Skip to content

Commit 0f56c37

Browse files
committed
chore: apply rustfmt
1 parent c3461cc commit 0f56c37

File tree

18 files changed

+146
-127
lines changed

18 files changed

+146
-127
lines changed

crates/bitcoind_rpc/src/lib.rs

+11-10
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`] until it returns `Ok(None)` (which means the chain tip is reached). A
@@ -47,8 +48,8 @@ pub struct Emitter<C> {
4748
/// A set of txids currently assumed to still be in the mempool.
4849
///
4950
/// This is used to detect mempool evictions by comparing the set against the latest mempool
50-
/// snapshot from bitcoind. Any txid in this set that is missing from the snapshot is considered
51-
/// evicted.
51+
/// snapshot from bitcoind. Any txid in this set that is missing from the snapshot is
52+
/// considered evicted.
5253
///
5354
/// When the emitter emits a block, confirmed txids are removed from this set. This prevents
5455
/// confirmed transactions from being mistakenly marked with an `evicted_at` timestamp.
@@ -124,8 +125,8 @@ where
124125
// Loop to make sure that the fetched mempool content and the fetched tip are consistent
125126
// with one another.
126127
let (raw_mempool, raw_mempool_txids, rpc_height, rpc_block_hash) = loop {
127-
// Determine if height and hash matches the best block from the RPC. Evictions are deferred
128-
// if we are not at the best block.
128+
// Determine if height and hash matches the best block from the RPC. Evictions are
129+
// deferred if we are not at the best block.
129130
let height = client.get_block_count()?;
130131
let hash = client.get_block_hash(height)?;
131132

@@ -232,9 +233,9 @@ pub struct MempoolEvent {
232233
///
233234
/// To understand the second condition, consider a receiver which filters transactions based on
234235
/// whether it alters the UTXO set of tracked script pubkeys. If an emitted mempool transaction
235-
/// spends a tracked UTXO which is confirmed at height `h`, but the receiver has only seen up to
236-
/// block of height `h-1`, we want to re-emit this transaction until the receiver has seen the
237-
/// block at height `h`.
236+
/// spends a tracked UTXO which is confirmed at height `h`, but the receiver has only seen up
237+
/// to block of height `h-1`, we want to re-emit this transaction until the receiver has
238+
/// seen the block at height `h`.
238239
pub new_txs: Vec<(Transaction, u64)>,
239240

240241
/// [`Txid`]s of all transactions that have been evicted from mempool.
@@ -263,8 +264,8 @@ pub struct BlockEvent<B> {
263264
/// The checkpoint of the new block.
264265
///
265266
/// A [`CheckPoint`] is a node of a linked list of [`BlockId`]s. This checkpoint is linked to
266-
/// all [`BlockId`]s originally passed in [`Emitter::new`] as well as emitted blocks since then.
267-
/// These blocks are guaranteed to be of the same chain.
267+
/// all [`BlockId`]s originally passed in [`Emitter::new`] as well as emitted blocks since
268+
/// then. These blocks are guaranteed to be of the same chain.
268269
///
269270
/// This is important as BDK structures require block-to-apply to be connected with another
270271
/// block in the original chain.

crates/chain/src/indexed_tx_graph.rs

+5-2
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);
@@ -341,7 +342,9 @@ where
341342
{
342343
/// List txids that are expected to exist under the given spks.
343344
///
344-
/// This is used to fill [`SyncRequestBuilder::expected_spk_txids`](bdk_core::spk_client::SyncRequestBuilder::expected_spk_txids).
345+
/// This is used to fill
346+
/// [`SyncRequestBuilder::expected_spk_txids`](bdk_core::spk_client::SyncRequestBuilder::expected_spk_txids).
347+
///
345348
///
346349
/// The spk index range can be contrained with `range`.
347350
///

crates/chain/src/indexer/keychain_txout.rs

+6-6
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

+19-16
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

+5-5
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

+11-9
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

@@ -584,9 +585,9 @@ fn merge_chains(
584585
let mut is_update_height_superset_of_original = true;
585586

586587
// To find the difference between the new chain and the original we iterate over both of them
587-
// from the tip backwards in tandem. We are always dealing with the highest one from either chain
588-
// first and move to the next highest. The crucial logic is applied when they have blocks at the
589-
// same height.
588+
// from the tip backwards in tandem. We are always dealing with the highest one from either
589+
// chain first and move to the next highest. The crucial logic is applied when they have
590+
// blocks at the same height.
590591
loop {
591592
if curr_orig.is_none() {
592593
curr_orig = orig.next();
@@ -620,9 +621,10 @@ fn merge_chains(
620621
if o.hash() == u.hash() {
621622
// We have found our point of agreement 🎉 -- we require that the previous (i.e.
622623
// higher because we are iterating backwards) block in the original chain was
623-
// invalidated (if it exists). This ensures that there is an unambiguous point of
624-
// connection to the original chain from the update chain (i.e. we know the
625-
// precisely which original blocks are invalid).
624+
// invalidated (if it exists). This ensures that there is an unambiguous point
625+
// of connection to the original chain from the update chain
626+
// (i.e. we know the precisely which original blocks are
627+
// invalid).
626628
if !prev_orig_was_invalidated && !point_of_agreement_found {
627629
if let (Some(prev_orig), Some(_prev_update)) = (&prev_orig, &prev_update) {
628630
return Err(CannotConnectError {

crates/chain/src/spk_iter.rs

+4-4
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
}

0 commit comments

Comments
 (0)