]> git.bitcoin.ninja Git - rust-lightning/commitdiff
`rustfmt`: Reformat `lightning-transaction-sync/src/common.rs`
authorElias Rohrer <dev@tnull.de>
Thu, 6 Jun 2024 07:21:15 +0000 (09:21 +0200)
committerElias Rohrer <dev@tnull.de>
Fri, 7 Jun 2024 09:35:15 +0000 (11:35 +0200)
lightning-transaction-sync/src/common.rs
rustfmt_excluded_files

index d68ac95914e2461396b8df160316651de5b2ffc8..420d7d8a9575f8672ce3111a52d000270c141a4e 100644 (file)
@@ -1,12 +1,11 @@
-use lightning::chain::{Confirm, WatchedOutput};
-use lightning::chain::channelmonitor::ANTI_REORG_DELAY;
-use bitcoin::{Txid, BlockHash, Transaction, OutPoint};
 use bitcoin::block::Header;
+use bitcoin::{BlockHash, OutPoint, Transaction, Txid};
+use lightning::chain::channelmonitor::ANTI_REORG_DELAY;
+use lightning::chain::{Confirm, WatchedOutput};
 
-use std::collections::{HashSet, HashMap};
+use std::collections::{HashMap, HashSet};
 use std::ops::Deref;
 
-
 // Represents the current state.
 pub(crate) struct SyncState {
        // Transactions that were previously processed, but must not be forgotten
@@ -35,10 +34,9 @@ impl SyncState {
                }
        }
        pub fn sync_unconfirmed_transactions<C: Deref>(
-               &mut self, confirmables: &Vec<C>,
-               unconfirmed_txs: Vec<Txid>,
-       )
-               where C::Target: Confirm,
+               &mut self, confirmables: &Vec<C>, unconfirmed_txs: Vec<Txid>,
+       ) where
+               C::Target: Confirm,
        {
                for txid in unconfirmed_txs {
                        for c in confirmables {
@@ -49,22 +47,23 @@ impl SyncState {
 
                        // If a previously-confirmed output spend is unconfirmed, re-add the watched output to
                        // the tracking map.
-                       self.outputs_spends_pending_threshold_conf.retain(|(conf_txid, _, prev_outpoint, output)| {
-                               if txid == *conf_txid {
-                                       self.watched_outputs.insert(*prev_outpoint, output.clone());
-                                       false
-                               } else {
-                                       true
-                               }
-                       })
+                       self.outputs_spends_pending_threshold_conf.retain(
+                               |(conf_txid, _, prev_outpoint, output)| {
+                                       if txid == *conf_txid {
+                                               self.watched_outputs.insert(*prev_outpoint, output.clone());
+                                               false
+                                       } else {
+                                               true
+                                       }
+                               },
+                       )
                }
        }
 
        pub fn sync_confirmed_transactions<C: Deref>(
-               &mut self, confirmables: &Vec<C>,
-               confirmed_txs: Vec<ConfirmedTx>
-       )
-               where C::Target: Confirm,
+               &mut self, confirmables: &Vec<C>, confirmed_txs: Vec<ConfirmedTx>,
+       ) where
+               C::Target: Confirm,
        {
                for ctx in confirmed_txs {
                        for c in confirmables {
@@ -79,20 +78,19 @@ impl SyncState {
 
                        for input in &ctx.tx.input {
                                if let Some(output) = self.watched_outputs.remove(&input.previous_output) {
-                                       self.outputs_spends_pending_threshold_conf.push((ctx.tx.txid(), ctx.block_height, input.previous_output, output));
+                                       let spent = (ctx.tx.txid(), ctx.block_height, input.previous_output, output);
+                                       self.outputs_spends_pending_threshold_conf.push(spent);
                                }
                        }
                }
        }
 
        pub fn prune_output_spends(&mut self, cur_height: u32) {
-               self.outputs_spends_pending_threshold_conf.retain(|(_, conf_height, _, _)| {
-                       cur_height < conf_height + ANTI_REORG_DELAY - 1
-               });
+               self.outputs_spends_pending_threshold_conf
+                       .retain(|(_, conf_height, _, _)| cur_height < conf_height + ANTI_REORG_DELAY - 1);
        }
 }
 
-
 // A queue that is to be filled by `Filter` and drained during the next syncing round.
 pub(crate) struct FilterQueue {
        // Transactions that were registered via the `Filter` interface and have to be processed.
@@ -103,10 +101,7 @@ pub(crate) struct FilterQueue {
 
 impl FilterQueue {
        pub fn new() -> Self {
-               Self {
-                       transactions: HashSet::new(),
-                       outputs: HashMap::new(),
-               }
+               Self { transactions: HashSet::new(), outputs: HashMap::new() }
        }
 
        // Processes the transaction and output queues and adds them to the given [`SyncState`].
index 36d85ef2061b4056d24c268ec3d1157cc9f5a574..8cc53a530759e8b9fc1a7caf24ae413d8b8f21af 100644 (file)
 ./lightning-rapid-gossip-sync/src/error.rs
 ./lightning-rapid-gossip-sync/src/lib.rs
 ./lightning-rapid-gossip-sync/src/processing.rs
-./lightning-transaction-sync/src/common.rs
 ./lightning-transaction-sync/src/electrum.rs
 ./lightning-transaction-sync/src/error.rs
 ./lightning-transaction-sync/src/esplora.rs