Skip to content

Commit 4cd92bf

Browse files
rustfmt: apply fn_single_line to codebase
1 parent 38ee5c5 commit 4cd92bf

18 files changed

+150
-360
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,8 @@ impl peer_handler::SocketDescriptor for SocketDescriptor {
309309
}
310310
impl Eq for SocketDescriptor {}
311311
impl PartialEq for SocketDescriptor {
312-
fn eq(&self, o: &Self) -> bool {
313-
self.id == o.id
314-
}
312+
fn eq(&self, o: &Self) -> bool { self.id == o.id }
315313
}
316314
impl Hash for SocketDescriptor {
317-
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
318-
self.id.hash(state);
319-
}
315+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { self.id.hash(state); }
320316
}

lightning/src/chain/chaininterface.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,7 @@ impl ChainWatchInterface for ChainWatchInterfaceUtil {
345345
(matched, matched_index)
346346
}
347347

348-
fn reentered(&self) -> usize {
349-
self.reentered.load(Ordering::Relaxed)
350-
}
348+
fn reentered(&self) -> usize { self.reentered.load(Ordering::Relaxed) }
351349
}
352350

353351
impl ChainWatchInterfaceUtil {

lightning/src/chain/keysinterface.rs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,12 @@ pub struct InMemoryChannelKeys {
194194
}
195195

196196
impl ChannelKeys for InMemoryChannelKeys {
197-
fn funding_key(&self) -> &SecretKey {
198-
&self.funding_key
199-
}
200-
fn revocation_base_key(&self) -> &SecretKey {
201-
&self.revocation_base_key
202-
}
203-
fn payment_base_key(&self) -> &SecretKey {
204-
&self.payment_base_key
205-
}
206-
fn delayed_payment_base_key(&self) -> &SecretKey {
207-
&self.delayed_payment_base_key
208-
}
209-
fn htlc_base_key(&self) -> &SecretKey {
210-
&self.htlc_base_key
211-
}
212-
fn commitment_seed(&self) -> &[u8; 32] {
213-
&self.commitment_seed
214-
}
197+
fn funding_key(&self) -> &SecretKey { &self.funding_key }
198+
fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key }
199+
fn payment_base_key(&self) -> &SecretKey { &self.payment_base_key }
200+
fn delayed_payment_base_key(&self) -> &SecretKey { &self.delayed_payment_base_key }
201+
fn htlc_base_key(&self) -> &SecretKey { &self.htlc_base_key }
202+
fn commitment_seed(&self) -> &[u8; 32] { &self.commitment_seed }
215203

216204
fn sign_remote_commitment<T: secp256k1::Signing>(&self,
217205
channel_value_satoshis: u64,
@@ -418,17 +406,11 @@ impl KeysManager {
418406
impl KeysInterface for KeysManager {
419407
type ChanKeySigner = InMemoryChannelKeys;
420408

421-
fn get_node_secret(&self) -> SecretKey {
422-
self.node_secret.clone()
423-
}
409+
fn get_node_secret(&self) -> SecretKey { self.node_secret.clone() }
424410

425-
fn get_destination_script(&self) -> Script {
426-
self.destination_script.clone()
427-
}
411+
fn get_destination_script(&self) -> Script { self.destination_script.clone() }
428412

429-
fn get_shutdown_pubkey(&self) -> PublicKey {
430-
self.shutdown_pubkey.clone()
431-
}
413+
fn get_shutdown_pubkey(&self) -> PublicKey { self.shutdown_pubkey.clone() }
432414

433415
fn get_channel_keys(&self, _inbound: bool) -> InMemoryChannelKeys {
434416
// We only seriously intend to rely on the channel_master_key for true secure

lightning/src/chain/transaction.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ pub struct OutPoint {
1717

1818
impl OutPoint {
1919
/// Creates a new `OutPoint` from the txid and the index.
20-
pub fn new(txid: Sha256dHash, index: u16) -> OutPoint {
21-
OutPoint { txid, index }
22-
}
20+
pub fn new(txid: Sha256dHash, index: u16) -> OutPoint { OutPoint { txid, index } }
2321

2422
/// Convert an `OutPoint` to a lightning channel id.
2523
pub fn to_channel_id(&self) -> [u8; 32] {

lightning/src/ln/chan_utils.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,7 @@ impl LocalCommitmentTransaction {
423423
Self { tx }
424424
}
425425

426-
pub fn txid(&self) -> Sha256dHash {
427-
self.tx.txid()
428-
}
426+
pub fn txid(&self) -> Sha256dHash { self.tx.txid() }
429427

430428
pub fn has_local_sig(&self) -> bool {
431429
if self.tx.input.len() != 1 {
@@ -471,19 +469,15 @@ impl LocalCommitmentTransaction {
471469
self.tx.input[0].witness.push(funding_redeemscript.as_bytes().to_vec());
472470
}
473471

474-
pub fn without_valid_witness(&self) -> &Transaction {
475-
&self.tx
476-
}
472+
pub fn without_valid_witness(&self) -> &Transaction { &self.tx }
477473
pub fn with_valid_witness(&self) -> &Transaction {
478474
assert!(self.has_local_sig());
479475
&self.tx
480476
}
481477
}
482478
impl PartialEq for LocalCommitmentTransaction {
483479
// We dont care whether we are signed in equality comparison
484-
fn eq(&self, o: &Self) -> bool {
485-
self.txid() == o.txid()
486-
}
480+
fn eq(&self, o: &Self) -> bool { self.txid() == o.txid() }
487481
}
488482
impl Writeable for LocalCommitmentTransaction {
489483
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {

lightning/src/ln/channel.rs

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,15 +3595,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
35953595

35963596
// Public utilities:
35973597

3598-
pub fn channel_id(&self) -> [u8; 32] {
3599-
self.channel_id
3600-
}
3598+
pub fn channel_id(&self) -> [u8; 32] { self.channel_id }
36013599

36023600
/// Gets the "user_id" value passed into the construction of this channel. It has no special
36033601
/// meaning and exists only to allow users to have a persistent identifier of a channel.
3604-
pub fn get_user_id(&self) -> u64 {
3605-
self.user_id
3606-
}
3602+
pub fn get_user_id(&self) -> u64 { self.user_id }
36073603

36083604
/// May only be called after funding has been initiated (ie is_funding_initiated() is true)
36093605
pub fn channel_monitor(&mut self) -> &mut ChannelMonitor {
@@ -3616,43 +3612,27 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
36163612
/// Guaranteed to be Some after both FundingLocked messages have been exchanged (and, thus,
36173613
/// is_usable() returns true).
36183614
/// Allowed in any state (including after shutdown)
3619-
pub fn get_short_channel_id(&self) -> Option<u64> {
3620-
self.short_channel_id
3621-
}
3615+
pub fn get_short_channel_id(&self) -> Option<u64> { self.short_channel_id }
36223616

36233617
/// Returns the funding_txo we either got from our peer, or were given by
36243618
/// get_outbound_funding_created.
3625-
pub fn get_funding_txo(&self) -> Option<OutPoint> {
3626-
self.channel_monitor.get_funding_txo()
3627-
}
3619+
pub fn get_funding_txo(&self) -> Option<OutPoint> { self.channel_monitor.get_funding_txo() }
36283620

36293621
/// Allowed in any state (including after shutdown)
3630-
pub fn get_their_node_id(&self) -> PublicKey {
3631-
self.their_node_id
3632-
}
3622+
pub fn get_their_node_id(&self) -> PublicKey { self.their_node_id }
36333623

36343624
/// Allowed in any state (including after shutdown)
3635-
pub fn get_our_htlc_minimum_msat(&self) -> u64 {
3636-
self.our_htlc_minimum_msat
3637-
}
3625+
pub fn get_our_htlc_minimum_msat(&self) -> u64 { self.our_htlc_minimum_msat }
36383626

36393627
/// Allowed in any state (including after shutdown)
3640-
pub fn get_their_htlc_minimum_msat(&self) -> u64 {
3641-
self.our_htlc_minimum_msat
3642-
}
3628+
pub fn get_their_htlc_minimum_msat(&self) -> u64 { self.our_htlc_minimum_msat }
36433629

3644-
pub fn get_value_satoshis(&self) -> u64 {
3645-
self.channel_value_satoshis
3646-
}
3630+
pub fn get_value_satoshis(&self) -> u64 { self.channel_value_satoshis }
36473631

3648-
pub fn get_fee_proportional_millionths(&self) -> u32 {
3649-
self.config.fee_proportional_millionths
3650-
}
3632+
pub fn get_fee_proportional_millionths(&self) -> u32 { self.config.fee_proportional_millionths }
36513633

36523634
#[cfg(test)]
3653-
pub fn get_feerate(&self) -> u64 {
3654-
self.feerate_per_kw
3655-
}
3635+
pub fn get_feerate(&self) -> u64 { self.feerate_per_kw }
36563636

36573637
pub fn get_cur_local_commitment_transaction_number(&self) -> u64 {
36583638
self.cur_local_commitment_transaction_number + 1
@@ -3672,9 +3652,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
36723652
}
36733653

36743654
#[cfg(test)]
3675-
pub fn get_local_keys(&self) -> &ChanSigner {
3676-
&self.local_keys
3677-
}
3655+
pub fn get_local_keys(&self) -> &ChanSigner { &self.local_keys }
36783656

36793657
#[cfg(test)]
36803658
pub fn get_value_stat(&self) -> ChannelValueStat {
@@ -3705,17 +3683,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
37053683
}
37063684

37073685
/// Allowed in any state (including after shutdown)
3708-
pub fn get_channel_update_count(&self) -> u32 {
3709-
self.channel_update_count
3710-
}
3686+
pub fn get_channel_update_count(&self) -> u32 { self.channel_update_count }
37113687

3712-
pub fn should_announce(&self) -> bool {
3713-
self.config.announced_channel
3714-
}
3688+
pub fn should_announce(&self) -> bool { self.config.announced_channel }
37153689

3716-
pub fn is_outbound(&self) -> bool {
3717-
self.channel_outbound
3718-
}
3690+
pub fn is_outbound(&self) -> bool { self.channel_outbound }
37193691

37203692
/// Gets the fee we'd want to charge for adding an HTLC output to this Channel
37213693
/// Allowed in any state (including after shutdown)
@@ -3740,9 +3712,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
37403712
}
37413713

37423714
/// Returns true if we've ever received a message from the remote end for this Channel
3743-
pub fn have_received_message(&self) -> bool {
3744-
self.channel_state > (ChannelState::OurInitSent as u32)
3745-
}
3715+
pub fn have_received_message(&self) -> bool { self.channel_state > (ChannelState::OurInitSent as u32) }
37463716

37473717
/// Returns true if this channel is fully established and not known to be closing.
37483718
/// Allowed in any state (including after shutdown)
@@ -3767,9 +3737,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
37673737
}
37683738

37693739
/// Returns true if funding_created was sent/received.
3770-
pub fn is_funding_initiated(&self) -> bool {
3771-
self.channel_state >= ChannelState::FundingCreated as u32
3772-
}
3740+
pub fn is_funding_initiated(&self) -> bool { self.channel_state >= ChannelState::FundingCreated as u32 }
37733741

37743742
/// Returns true if this channel is fully shut down. True here implies that no further actions
37753743
/// may/will be taken on this channel, and thus this object should be freed. Any future changes
@@ -3783,25 +3751,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
37833751
}
37843752
}
37853753

3786-
pub fn to_disabled_staged(&mut self) {
3787-
self.network_sync = UpdateStatus::DisabledStaged;
3788-
}
3754+
pub fn to_disabled_staged(&mut self) { self.network_sync = UpdateStatus::DisabledStaged; }
37893755

3790-
pub fn to_disabled_marked(&mut self) {
3791-
self.network_sync = UpdateStatus::DisabledMarked;
3792-
}
3756+
pub fn to_disabled_marked(&mut self) { self.network_sync = UpdateStatus::DisabledMarked; }
37933757

3794-
pub fn to_fresh(&mut self) {
3795-
self.network_sync = UpdateStatus::Fresh;
3796-
}
3758+
pub fn to_fresh(&mut self) { self.network_sync = UpdateStatus::Fresh; }
37973759

3798-
pub fn is_disabled_staged(&self) -> bool {
3799-
self.network_sync == UpdateStatus::DisabledStaged
3800-
}
3760+
pub fn is_disabled_staged(&self) -> bool { self.network_sync == UpdateStatus::DisabledStaged }
38013761

3802-
pub fn is_disabled_marked(&self) -> bool {
3803-
self.network_sync == UpdateStatus::DisabledMarked
3804-
}
3762+
pub fn is_disabled_marked(&self) -> bool { self.network_sync == UpdateStatus::DisabledMarked }
38053763

38063764
/// Called by channelmanager based on chain blocks being connected.
38073765
/// Note that we only need to use this to detect funding_signed, anything else is handled by
@@ -5116,9 +5074,7 @@ mod tests {
51165074
fee_est: u64,
51175075
}
51185076
impl FeeEstimator for TestFeeEstimator {
5119-
fn get_est_sat_per_1000_weight(&self, _: ConfirmationTarget) -> u64 {
5120-
self.fee_est
5121-
}
5077+
fn get_est_sat_per_1000_weight(&self, _: ConfirmationTarget) -> u64 { self.fee_est }
51225078
}
51235079

51245080
#[test]
@@ -5160,15 +5116,11 @@ mod tests {
51605116
PublicKey::from_secret_key(&secp_ctx, &channel_close_key)
51615117
}
51625118

5163-
fn get_channel_keys(&self, _inbound: bool) -> InMemoryChannelKeys {
5164-
self.chan_keys.clone()
5165-
}
5119+
fn get_channel_keys(&self, _inbound: bool) -> InMemoryChannelKeys { self.chan_keys.clone() }
51665120
fn get_onion_rand(&self) -> (SecretKey, [u8; 32]) {
51675121
panic!();
51685122
}
5169-
fn get_channel_id(&self) -> [u8; 32] {
5170-
[0; 32]
5171-
}
5123+
fn get_channel_id(&self) -> [u8; 32] { [0; 32] }
51725124
}
51735125

51745126
#[test]

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,9 +2012,7 @@ impl<ChanSigner: ChannelKeys> ChannelManager<ChanSigner> {
20122012
}
20132013

20142014
/// Gets the node_id held by this ChannelManager
2015-
pub fn get_our_node_id(&self) -> PublicKey {
2016-
PublicKey::from_secret_key(&self.secp_ctx, &self.our_network_key)
2017-
}
2015+
pub fn get_our_node_id(&self) -> PublicKey { PublicKey::from_secret_key(&self.secp_ctx, &self.our_network_key) }
20182016

20192017
/// Used to restore channels to normal operation after a
20202018
/// ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update

lightning/src/ln/channelmonitor.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,9 +1447,7 @@ impl ChannelMonitor {
14471447
/// the "reorg path" (ie not just starting at the same height but starting at the highest
14481448
/// common block that appears on your best chain as well as on the chain which contains the
14491449
/// last block hash returned) upon deserializing the object!
1450-
pub fn write_for_disk<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
1451-
self.write(writer, true)
1452-
}
1450+
pub fn write_for_disk<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> { self.write(writer, true) }
14531451

14541452
/// Encodes this monitor into the given writer, suitable for sending to a remote watchtower
14551453
///
@@ -1484,9 +1482,7 @@ impl ChannelMonitor {
14841482
min
14851483
}
14861484

1487-
pub(super) fn get_cur_remote_commitment_number(&self) -> u64 {
1488-
self.current_remote_commitment_number
1489-
}
1485+
pub(super) fn get_cur_remote_commitment_number(&self) -> u64 { self.current_remote_commitment_number }
14901486

14911487
pub(super) fn get_cur_local_commitment_number(&self) -> u64 {
14921488
if let &Some(ref local_tx) = &self.current_local_signed_commitment_tx {

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6579,14 +6579,10 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
65796579
}
65806580

65816581
#[test]
6582-
fn test_fail_backwards_latest_remote_announce_a() {
6583-
do_test_fail_backwards_unrevoked_remote_announce(false, true);
6584-
}
6582+
fn test_fail_backwards_latest_remote_announce_a() { do_test_fail_backwards_unrevoked_remote_announce(false, true); }
65856583

65866584
#[test]
6587-
fn test_fail_backwards_latest_remote_announce_b() {
6588-
do_test_fail_backwards_unrevoked_remote_announce(true, true);
6589-
}
6585+
fn test_fail_backwards_latest_remote_announce_b() { do_test_fail_backwards_unrevoked_remote_announce(true, true); }
65906586

65916587
#[test]
65926588
fn test_fail_backwards_previous_remote_announce() {

0 commit comments

Comments
 (0)