Skip to content

Commit 3ead263

Browse files
committed
rustfmt: Reformat lightning-transaction-sync/src/common.rs
1 parent 777ce7b commit 3ead263

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed

lightning-transaction-sync/src/common.rs

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use lightning::chain::{Confirm, WatchedOutput};
2-
use lightning::chain::channelmonitor::ANTI_REORG_DELAY;
3-
use bitcoin::{Txid, BlockHash, Transaction, OutPoint};
41
use bitcoin::block::Header;
2+
use bitcoin::{BlockHash, OutPoint, Transaction, Txid};
3+
use lightning::chain::channelmonitor::ANTI_REORG_DELAY;
4+
use lightning::chain::{Confirm, WatchedOutput};
55

6-
use std::collections::{HashSet, HashMap};
6+
use std::collections::{HashMap, HashSet};
77
use std::ops::Deref;
88

9-
109
// Represents the current state.
1110
pub(crate) struct SyncState {
1211
// Transactions that were previously processed, but must not be forgotten
@@ -35,10 +34,9 @@ impl SyncState {
3534
}
3635
}
3736
pub fn sync_unconfirmed_transactions<C: Deref>(
38-
&mut self, confirmables: &Vec<C>,
39-
unconfirmed_txs: Vec<Txid>,
40-
)
41-
where C::Target: Confirm,
37+
&mut self, confirmables: &Vec<C>, unconfirmed_txs: Vec<Txid>,
38+
) where
39+
C::Target: Confirm,
4240
{
4341
for txid in unconfirmed_txs {
4442
for c in confirmables {
@@ -49,22 +47,23 @@ impl SyncState {
4947

5048
// If a previously-confirmed output spend is unconfirmed, re-add the watched output to
5149
// the tracking map.
52-
self.outputs_spends_pending_threshold_conf.retain(|(conf_txid, _, prev_outpoint, output)| {
53-
if txid == *conf_txid {
54-
self.watched_outputs.insert(*prev_outpoint, output.clone());
55-
false
56-
} else {
57-
true
58-
}
59-
})
50+
self.outputs_spends_pending_threshold_conf.retain(
51+
|(conf_txid, _, prev_outpoint, output)| {
52+
if txid == *conf_txid {
53+
self.watched_outputs.insert(*prev_outpoint, output.clone());
54+
false
55+
} else {
56+
true
57+
}
58+
},
59+
)
6060
}
6161
}
6262

6363
pub fn sync_confirmed_transactions<C: Deref>(
64-
&mut self, confirmables: &Vec<C>,
65-
confirmed_txs: Vec<ConfirmedTx>
66-
)
67-
where C::Target: Confirm,
64+
&mut self, confirmables: &Vec<C>, confirmed_txs: Vec<ConfirmedTx>,
65+
) where
66+
C::Target: Confirm,
6867
{
6968
for ctx in confirmed_txs {
7069
for c in confirmables {
@@ -79,20 +78,19 @@ impl SyncState {
7978

8079
for input in &ctx.tx.input {
8180
if let Some(output) = self.watched_outputs.remove(&input.previous_output) {
82-
self.outputs_spends_pending_threshold_conf.push((ctx.tx.txid(), ctx.block_height, input.previous_output, output));
81+
let spent = (ctx.tx.txid(), ctx.block_height, input.previous_output, output);
82+
self.outputs_spends_pending_threshold_conf.push(spent);
8383
}
8484
}
8585
}
8686
}
8787

8888
pub fn prune_output_spends(&mut self, cur_height: u32) {
89-
self.outputs_spends_pending_threshold_conf.retain(|(_, conf_height, _, _)| {
90-
cur_height < conf_height + ANTI_REORG_DELAY - 1
91-
});
89+
self.outputs_spends_pending_threshold_conf
90+
.retain(|(_, conf_height, _, _)| cur_height < conf_height + ANTI_REORG_DELAY - 1);
9291
}
9392
}
9493

95-
9694
// A queue that is to be filled by `Filter` and drained during the next syncing round.
9795
pub(crate) struct FilterQueue {
9896
// Transactions that were registered via the `Filter` interface and have to be processed.
@@ -103,10 +101,7 @@ pub(crate) struct FilterQueue {
103101

104102
impl FilterQueue {
105103
pub fn new() -> Self {
106-
Self {
107-
transactions: HashSet::new(),
108-
outputs: HashMap::new(),
109-
}
104+
Self { transactions: HashSet::new(), outputs: HashMap::new() }
110105
}
111106

112107
// Processes the transaction and output queues and adds them to the given [`SyncState`].

rustfmt_excluded_files

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
./lightning-rapid-gossip-sync/src/error.rs
160160
./lightning-rapid-gossip-sync/src/lib.rs
161161
./lightning-rapid-gossip-sync/src/processing.rs
162-
./lightning-transaction-sync/src/common.rs
163162
./lightning-transaction-sync/src/electrum.rs
164163
./lightning-transaction-sync/src/error.rs
165164
./lightning-transaction-sync/src/esplora.rs

0 commit comments

Comments
 (0)