Skip to content

Commit 36fe491

Browse files
authored
Merge pull request #3825 from TheBlueMatt/2025-05-re-enable-rustfmt
Re-enable `rustfmt` on the `lightning` crate
2 parents c6caad8 + aed8a10 commit 36fe491

File tree

4 files changed

+63
-65
lines changed

4 files changed

+63
-65
lines changed

lightning/src/chain/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(rustfmt, rustfmt_skip)]
2-
31
// This file is Copyright its original authors, visible in version control
42
// history.
53
//
@@ -13,26 +11,26 @@
1311
1412
use bitcoin::block::{Block, Header};
1513
use bitcoin::constants::genesis_block;
16-
use bitcoin::script::{Script, ScriptBuf};
1714
use bitcoin::hash_types::{BlockHash, Txid};
1815
use bitcoin::network::Network;
16+
use bitcoin::script::{Script, ScriptBuf};
1917
use bitcoin::secp256k1::PublicKey;
2018

2119
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent};
22-
use crate::ln::types::ChannelId;
23-
use crate::sign::ecdsa::EcdsaChannelSigner;
2420
use crate::chain::transaction::{OutPoint, TransactionData};
2521
use crate::impl_writeable_tlv_based;
22+
use crate::ln::types::ChannelId;
23+
use crate::sign::ecdsa::EcdsaChannelSigner;
2624

2725
#[allow(unused_imports)]
2826
use crate::prelude::*;
2927

3028
pub mod chaininterface;
3129
pub mod chainmonitor;
3230
pub mod channelmonitor;
33-
pub mod transaction;
3431
pub(crate) mod onchaintx;
3532
pub(crate) mod package;
33+
pub mod transaction;
3634

3735
/// The best known block as identified by its hash and height.
3836
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
@@ -47,10 +45,7 @@ impl BestBlock {
4745
/// Constructs a `BestBlock` that represents the genesis block at height 0 of the given
4846
/// network.
4947
pub fn from_network(network: Network) -> Self {
50-
BestBlock {
51-
block_hash: genesis_block(network).header.block_hash(),
52-
height: 0,
53-
}
48+
BestBlock { block_hash: genesis_block(network).header.block_hash(), height: 0 }
5449
}
5550

5651
/// Returns a `BestBlock` as identified by the given block hash and height.
@@ -67,7 +62,6 @@ impl_writeable_tlv_based!(BestBlock, {
6762
(2, height, required),
6863
});
6964

70-
7165
/// The `Listen` trait is used to notify when blocks have been connected or disconnected from the
7266
/// chain.
7367
///
@@ -289,7 +283,9 @@ pub trait Watch<ChannelSigner: EcdsaChannelSigner> {
289283
/// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
290284
/// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
291285
/// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
292-
fn watch_channel(&self, channel_id: ChannelId, monitor: ChannelMonitor<ChannelSigner>) -> Result<ChannelMonitorUpdateStatus, ()>;
286+
fn watch_channel(
287+
&self, channel_id: ChannelId, monitor: ChannelMonitor<ChannelSigner>,
288+
) -> Result<ChannelMonitorUpdateStatus, ()>;
293289

294290
/// Updates a channel identified by `channel_id` by applying `update` to its monitor.
295291
///
@@ -306,7 +302,9 @@ pub trait Watch<ChannelSigner: EcdsaChannelSigner> {
306302
/// [`ChannelMonitorUpdateStatus::UnrecoverableError`], see its documentation for more info.
307303
///
308304
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
309-
fn update_channel(&self, channel_id: ChannelId, update: &ChannelMonitorUpdate) -> ChannelMonitorUpdateStatus;
305+
fn update_channel(
306+
&self, channel_id: ChannelId, update: &ChannelMonitorUpdate,
307+
) -> ChannelMonitorUpdateStatus;
310308

311309
/// Returns any monitor events since the last call. Subsequent calls must only return new
312310
/// events.
@@ -317,7 +315,9 @@ pub trait Watch<ChannelSigner: EcdsaChannelSigner> {
317315
///
318316
/// For details on asynchronous [`ChannelMonitor`] updating and returning
319317
/// [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`].
320-
fn release_pending_monitor_events(&self) -> Vec<(OutPoint, ChannelId, Vec<MonitorEvent>, PublicKey)>;
318+
fn release_pending_monitor_events(
319+
&self,
320+
) -> Vec<(OutPoint, ChannelId, Vec<MonitorEvent>, PublicKey)>;
321321
}
322322

323323
/// The `Filter` trait defines behavior for indicating chain activity of interest pertaining to

lightning/src/lib.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(rustfmt, rustfmt_skip)]
2-
31
// This file is Copyright its original authors, visible in version control
42
// history.
53
//
@@ -32,18 +30,14 @@
3230
//! * `grind_signatures`
3331
3432
#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))]
35-
3633
#![deny(rustdoc::broken_intra_doc_links)]
3734
#![deny(rustdoc::private_intra_doc_links)]
38-
3935
// In general, rust is absolutely horrid at supporting users doing things like,
4036
// for example, compiling Rust code for real environments. Disable useless lints
4137
// that don't do anything but annoy us and cant actually ever be resolved.
4238
#![allow(bare_trait_objects)]
4339
#![allow(ellipsis_inclusive_range_patterns)]
44-
4540
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
46-
4741
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
4842

4943
#[cfg(all(fuzzing, test))]
@@ -61,24 +55,29 @@ pub extern crate lightning_invoice as bolt11_invoice;
6155
#[cfg(any(test, feature = "std"))]
6256
extern crate core;
6357

64-
#[cfg(any(test, feature = "_test_utils"))] extern crate regex;
58+
#[cfg(any(test, feature = "_test_utils"))]
59+
extern crate regex;
6560

66-
#[cfg(not(feature = "std"))] extern crate libm;
61+
#[cfg(not(feature = "std"))]
62+
extern crate libm;
6763

68-
#[cfg(ldk_bench)] extern crate criterion;
64+
#[cfg(ldk_bench)]
65+
extern crate criterion;
6966

70-
#[cfg(all(feature = "std", test))] extern crate parking_lot;
67+
#[cfg(all(feature = "std", test))]
68+
extern crate parking_lot;
7169

7270
#[macro_use]
7371
pub mod util;
72+
73+
pub mod blinded_path;
7474
pub mod chain;
75+
pub mod events;
7576
pub mod ln;
7677
pub mod offers;
78+
pub mod onion_message;
7779
pub mod routing;
7880
pub mod sign;
79-
pub mod onion_message;
80-
pub mod blinded_path;
81-
pub mod events;
8281

8382
pub(crate) mod crypto;
8483

@@ -96,7 +95,7 @@ pub mod io_extras {
9695
pub use bitcoin::io::sink;
9796

9897
pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> Result<u64, io::Error>
99-
where
98+
where
10099
R: Read,
101100
W: Write,
102101
{
@@ -106,7 +105,10 @@ pub mod io_extras {
106105
loop {
107106
match reader.read(&mut buf) {
108107
Ok(0) => break,
109-
Ok(n) => { writer.write_all(&buf[0..n])?; count += n as u64; },
108+
Ok(n) => {
109+
writer.write_all(&buf[0..n])?;
110+
count += n as u64;
111+
},
110112
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {},
111113
Err(e) => return Err(e.into()),
112114
};
@@ -132,7 +134,7 @@ pub mod io_extras {
132134
mod prelude {
133135
#![allow(unused_imports)]
134136

135-
pub use alloc::{vec, vec::Vec, string::String, collections::VecDeque, boxed::Box};
137+
pub use alloc::{boxed::Box, collections::VecDeque, string::String, vec, vec::Vec};
136138

137139
pub use alloc::borrow::ToOwned;
138140
pub use alloc::string::ToString;

lightning/src/ln/mod.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(rustfmt, rustfmt_skip)]
2-
31
// This file is Copyright its original authors, visible in version control
42
// history.
53
//
@@ -15,15 +13,15 @@
1513
#[macro_use]
1614
pub mod functional_test_utils;
1715

18-
pub mod onion_payment;
19-
pub mod channelmanager;
16+
pub mod chan_utils;
2017
pub mod channel_keys;
2118
pub mod channel_state;
19+
pub mod channelmanager;
20+
mod features;
2221
pub mod inbound_payment;
2322
pub mod msgs;
23+
pub mod onion_payment;
2424
pub mod peer_handler;
25-
pub mod chan_utils;
26-
mod features;
2725
pub mod script;
2826
pub mod types;
2927

@@ -59,64 +57,64 @@ pub use onion_utils::process_onion_failure;
5957
#[cfg(fuzzing)]
6058
pub use onion_utils::AttributionData;
6159

60+
#[cfg(all(test, async_payments))]
61+
#[allow(unused_mut)]
62+
mod async_payments_tests;
6263
#[cfg(test)]
6364
#[allow(unused_mut)]
64-
pub mod bolt11_payment_tests;
65+
mod async_signer_tests;
6566
#[cfg(test)]
6667
#[allow(unused_mut)]
6768
mod blinded_payment_tests;
68-
#[cfg(all(test, async_payments))]
69+
#[cfg(test)]
6970
#[allow(unused_mut)]
70-
mod async_payments_tests;
71+
pub mod bolt11_payment_tests;
72+
#[cfg(test)]
73+
#[allow(unused_mut)]
74+
mod chanmon_update_fail_tests;
75+
#[cfg(test)]
76+
#[allow(unused_mut)]
77+
mod dual_funding_tests;
7178
#[cfg(any(test, feature = "_externalize_tests"))]
7279
#[allow(unused_mut)]
7380
pub mod functional_tests;
7481
#[cfg(any(test, feature = "_externalize_tests"))]
7582
#[allow(unused_mut)]
7683
pub mod htlc_reserve_unit_tests;
77-
#[cfg(any(test, feature = "_externalize_tests"))]
78-
#[allow(unused_mut)]
79-
pub mod update_fee_tests;
80-
#[cfg(all(test, splicing))]
81-
#[allow(unused_mut)]
82-
mod splicing_tests;
8384
#[cfg(test)]
8485
#[allow(unused_mut)]
8586
mod max_payment_path_len_tests;
8687
#[cfg(test)]
8788
#[allow(unused_mut)]
88-
mod payment_tests;
89-
#[cfg(test)]
90-
#[allow(unused_mut)]
91-
mod priv_short_conf_tests;
92-
#[cfg(test)]
93-
#[allow(unused_mut)]
94-
mod chanmon_update_fail_tests;
95-
#[cfg(test)]
96-
#[allow(unused_mut)]
97-
mod reorg_tests;
89+
mod monitor_tests;
9890
#[cfg(test)]
9991
#[allow(unused_mut)]
100-
mod reload_tests;
92+
mod offers_tests;
10193
#[cfg(test)]
10294
#[allow(unused_mut)]
10395
mod onion_route_tests;
10496
#[cfg(test)]
10597
#[allow(unused_mut)]
106-
mod monitor_tests;
98+
mod payment_tests;
10799
#[cfg(test)]
108100
#[allow(unused_mut)]
109-
mod shutdown_tests;
101+
mod priv_short_conf_tests;
110102
#[cfg(test)]
111103
mod quiescence_tests;
112104
#[cfg(test)]
113105
#[allow(unused_mut)]
114-
mod async_signer_tests;
106+
mod reload_tests;
115107
#[cfg(test)]
116108
#[allow(unused_mut)]
117-
mod offers_tests;
109+
mod reorg_tests;
118110
#[cfg(test)]
119111
#[allow(unused_mut)]
120-
mod dual_funding_tests;
112+
mod shutdown_tests;
113+
#[cfg(all(test, splicing))]
114+
#[allow(unused_mut)]
115+
mod splicing_tests;
116+
#[cfg(any(test, feature = "_externalize_tests"))]
117+
#[allow(unused_mut)]
118+
pub mod update_fee_tests;
121119

122120
pub use self::peer_channel_encryptor::LN_MAX_MSG_LEN;

lightning/src/routing/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(rustfmt, rustfmt_skip)]
2-
31
// This file is Copyright its original authors, visible in version control
42
// history.
53
//
@@ -11,10 +9,10 @@
119

1210
//! Structs and impls for receiving messages about the network and storing the topology live here.
1311
14-
pub mod utxo;
1512
pub mod gossip;
13+
mod log_approx;
1614
pub mod router;
1715
pub mod scoring;
18-
mod log_approx;
1916
#[cfg(test)]
2017
pub(crate) mod test_utils;
18+
pub mod utxo;

0 commit comments

Comments
 (0)