Skip to content

Re-enable rustfmt on the lightning crate #3825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions lightning/src/chain/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

// This file is Copyright its original authors, visible in version control
// history.
//
Expand All @@ -13,26 +11,26 @@

use bitcoin::block::{Block, Header};
use bitcoin::constants::genesis_block;
use bitcoin::script::{Script, ScriptBuf};
use bitcoin::hash_types::{BlockHash, Txid};
use bitcoin::network::Network;
use bitcoin::script::{Script, ScriptBuf};
use bitcoin::secp256k1::PublicKey;

use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent};
use crate::ln::types::ChannelId;
use crate::sign::ecdsa::EcdsaChannelSigner;
use crate::chain::transaction::{OutPoint, TransactionData};
use crate::impl_writeable_tlv_based;
use crate::ln::types::ChannelId;
use crate::sign::ecdsa::EcdsaChannelSigner;

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

pub mod chaininterface;
pub mod chainmonitor;
pub mod channelmonitor;
pub mod transaction;
pub(crate) mod onchaintx;
pub(crate) mod package;
pub mod transaction;

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

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


/// The `Listen` trait is used to notify when blocks have been connected or disconnected from the
/// chain.
///
Expand Down Expand Up @@ -289,7 +283,9 @@ pub trait Watch<ChannelSigner: EcdsaChannelSigner> {
/// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
/// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
/// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
fn watch_channel(&self, channel_id: ChannelId, monitor: ChannelMonitor<ChannelSigner>) -> Result<ChannelMonitorUpdateStatus, ()>;
fn watch_channel(
&self, channel_id: ChannelId, monitor: ChannelMonitor<ChannelSigner>,
) -> Result<ChannelMonitorUpdateStatus, ()>;

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

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

/// The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
Expand Down
34 changes: 18 additions & 16 deletions lightning/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

// This file is Copyright its original authors, visible in version control
// history.
//
Expand Down Expand Up @@ -32,18 +30,14 @@
//! * `grind_signatures`

#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))]

#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]

// In general, rust is absolutely horrid at supporting users doing things like,
// for example, compiling Rust code for real environments. Disable useless lints
// that don't do anything but annoy us and cant actually ever be resolved.
#![allow(bare_trait_objects)]
#![allow(ellipsis_inclusive_range_patterns)]

#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]

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

#[cfg(any(test, feature = "_test_utils"))] extern crate regex;
#[cfg(any(test, feature = "_test_utils"))]
extern crate regex;

#[cfg(not(feature = "std"))] extern crate libm;
#[cfg(not(feature = "std"))]
extern crate libm;

#[cfg(ldk_bench)] extern crate criterion;
#[cfg(ldk_bench)]
extern crate criterion;

#[cfg(all(feature = "std", test))] extern crate parking_lot;
#[cfg(all(feature = "std", test))]
extern crate parking_lot;

#[macro_use]
pub mod util;

pub mod blinded_path;
pub mod chain;
pub mod events;
pub mod ln;
pub mod offers;
pub mod onion_message;
pub mod routing;
pub mod sign;
pub mod onion_message;
pub mod blinded_path;
pub mod events;

pub(crate) mod crypto;

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

pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> Result<u64, io::Error>
where
where
R: Read,
W: Write,
{
Expand All @@ -106,7 +105,10 @@ pub mod io_extras {
loop {
match reader.read(&mut buf) {
Ok(0) => break,
Ok(n) => { writer.write_all(&buf[0..n])?; count += n as u64; },
Ok(n) => {
writer.write_all(&buf[0..n])?;
count += n as u64;
},
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {},
Err(e) => return Err(e.into()),
};
Expand All @@ -132,7 +134,7 @@ pub mod io_extras {
mod prelude {
#![allow(unused_imports)]

pub use alloc::{vec, vec::Vec, string::String, collections::VecDeque, boxed::Box};
pub use alloc::{boxed::Box, collections::VecDeque, string::String, vec, vec::Vec};

pub use alloc::borrow::ToOwned;
pub use alloc::string::ToString;
Expand Down
60 changes: 29 additions & 31 deletions lightning/src/ln/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

// This file is Copyright its original authors, visible in version control
// history.
//
Expand All @@ -15,15 +13,15 @@
#[macro_use]
pub mod functional_test_utils;

pub mod onion_payment;
pub mod channelmanager;
pub mod chan_utils;
pub mod channel_keys;
pub mod channel_state;
pub mod channelmanager;
mod features;
pub mod inbound_payment;
pub mod msgs;
pub mod onion_payment;
pub mod peer_handler;
pub mod chan_utils;
mod features;
pub mod script;
pub mod types;

Expand Down Expand Up @@ -59,64 +57,64 @@ pub use onion_utils::process_onion_failure;
#[cfg(fuzzing)]
pub use onion_utils::AttributionData;

#[cfg(all(test, async_payments))]
#[allow(unused_mut)]
mod async_payments_tests;
#[cfg(test)]
#[allow(unused_mut)]
pub mod bolt11_payment_tests;
mod async_signer_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod blinded_payment_tests;
#[cfg(all(test, async_payments))]
#[cfg(test)]
#[allow(unused_mut)]
mod async_payments_tests;
pub mod bolt11_payment_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod chanmon_update_fail_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod dual_funding_tests;
#[cfg(any(test, feature = "_externalize_tests"))]
#[allow(unused_mut)]
pub mod functional_tests;
#[cfg(any(test, feature = "_externalize_tests"))]
#[allow(unused_mut)]
pub mod htlc_reserve_unit_tests;
#[cfg(any(test, feature = "_externalize_tests"))]
#[allow(unused_mut)]
pub mod update_fee_tests;
#[cfg(all(test, splicing))]
#[allow(unused_mut)]
mod splicing_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod max_payment_path_len_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod payment_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod priv_short_conf_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod chanmon_update_fail_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod reorg_tests;
mod monitor_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod reload_tests;
mod offers_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod onion_route_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod monitor_tests;
mod payment_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod shutdown_tests;
mod priv_short_conf_tests;
#[cfg(test)]
mod quiescence_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod async_signer_tests;
mod reload_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod offers_tests;
mod reorg_tests;
#[cfg(test)]
#[allow(unused_mut)]
mod dual_funding_tests;
mod shutdown_tests;
#[cfg(all(test, splicing))]
#[allow(unused_mut)]
mod splicing_tests;
#[cfg(any(test, feature = "_externalize_tests"))]
#[allow(unused_mut)]
pub mod update_fee_tests;

pub use self::peer_channel_encryptor::LN_MAX_MSG_LEN;
6 changes: 2 additions & 4 deletions lightning/src/routing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

// This file is Copyright its original authors, visible in version control
// history.
//
Expand All @@ -11,10 +9,10 @@

//! Structs and impls for receiving messages about the network and storing the topology live here.

pub mod utxo;
pub mod gossip;
mod log_approx;
pub mod router;
pub mod scoring;
mod log_approx;
#[cfg(test)]
pub(crate) mod test_utils;
pub mod utxo;
Loading