Skip to content

Commit 88bb090

Browse files
committed
Align rustfmt.toml with rust-lightning
Now that `rust-lightning` has added `rustfmt` support, we make sure our coding style is aligned.
1 parent 299620e commit 88bb090

15 files changed

+167
-160
lines changed

rustfmt.toml

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
hard_tabs = true # use tab characters for indentation, spaces for alignment
2-
use_field_init_shorthand = true
3-
max_width = 100
41
use_small_heuristics = "Max"
52
fn_params_layout = "Compressed"
3+
hard_tabs = true
4+
use_field_init_shorthand = true
5+
max_width = 100
6+
match_block_trailing_comma = true
7+
# UNSTABLE: format_code_in_doc_comments = true
8+
# UNSTABLE: overflow_delimited_expr = true
9+
# UNSTABLE: comment_width = 100
10+
# UNSTABLE: format_macro_matchers = true
11+
# UNSTABLE: format_strings = true
12+
# UNSTABLE: group_imports = "StdExternalCrate"

src/builder.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ impl fmt::Display for BuildError {
134134
Self::InvalidSeedFile => write!(f, "Given seed file is invalid or could not be read."),
135135
Self::InvalidSystemTime => {
136136
write!(f, "System time is invalid. Clocks might have gone back in time.")
137-
}
137+
},
138138
Self::InvalidChannelMonitor => {
139139
write!(f, "Failed to watch a deserialized ChannelMonitor")
140-
}
140+
},
141141
Self::InvalidListeningAddresses => write!(f, "Given listening addresses are invalid."),
142142
Self::ReadFailed => write!(f, "Failed to read from store."),
143143
Self::WriteFailed => write!(f, "Failed to write to store."),
@@ -572,7 +572,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
572572
Arc::clone(&logger),
573573
));
574574
(blockchain, tx_sync, tx_broadcaster, fee_estimator)
575-
}
575+
},
576576
None => {
577577
// Default to Esplora client.
578578
let server_url = DEFAULT_ESPLORA_SERVER_URL.to_string();
@@ -590,7 +590,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
590590
Arc::clone(&logger),
591591
));
592592
(blockchain, tx_sync, tx_broadcaster, fee_estimator)
593-
}
593+
},
594594
};
595595

596596
let runtime = Arc::new(RwLock::new(None));
@@ -636,7 +636,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
636636
} else {
637637
return Err(BuildError::ReadFailed);
638638
}
639-
}
639+
},
640640
};
641641

642642
let scorer = match io::utils::read_scorer(
@@ -656,7 +656,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
656656
} else {
657657
return Err(BuildError::ReadFailed);
658658
}
659-
}
659+
},
660660
};
661661

662662
let scoring_fee_params = ProbabilisticScoringFeeParameters::default();
@@ -682,7 +682,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
682682
log_error!(logger, "Failed to read channel monitors: {}", e.to_string());
683683
return Err(BuildError::ReadFailed);
684684
}
685-
}
685+
},
686686
};
687687

688688
// Initialize the ChannelManager
@@ -794,7 +794,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
794794
BuildError::WriteFailed
795795
})?;
796796
p2p_source
797-
}
797+
},
798798
GossipSourceConfig::RapidGossipSync(rgs_server) => {
799799
let latest_sync_timestamp = io::utils::read_latest_rgs_sync_timestamp(
800800
Arc::clone(&kv_store),
@@ -807,7 +807,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
807807
Arc::clone(&network_graph),
808808
Arc::clone(&logger),
809809
))
810-
}
810+
},
811811
};
812812

813813
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
@@ -858,7 +858,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
858858
},
859859
GossipSync::None => {
860860
unreachable!("We must always have a gossip sync!");
861-
}
861+
},
862862
};
863863

864864
let cur_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).map_err(|e| {
@@ -883,10 +883,10 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
883883
let payment_store = match io::utils::read_payments(Arc::clone(&kv_store), Arc::clone(&logger)) {
884884
Ok(payments) => {
885885
Arc::new(PaymentStore::new(payments, Arc::clone(&kv_store), Arc::clone(&logger)))
886-
}
886+
},
887887
Err(_) => {
888888
return Err(BuildError::ReadFailed);
889-
}
889+
},
890890
};
891891

892892
let event_queue = match io::utils::read_event_queue(Arc::clone(&kv_store), Arc::clone(&logger))
@@ -898,7 +898,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
898898
} else {
899899
return Err(BuildError::ReadFailed);
900900
}
901-
}
901+
},
902902
};
903903

904904
let peer_store = match io::utils::read_peer_info(Arc::clone(&kv_store), Arc::clone(&logger)) {
@@ -909,7 +909,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
909909
} else {
910910
return Err(BuildError::ReadFailed);
911911
}
912-
}
912+
},
913913
};
914914

915915
let best_block = channel_manager.current_best_block();
@@ -928,7 +928,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
928928
)),
929929
Err(_) => {
930930
return Err(BuildError::ReadFailed);
931-
}
931+
},
932932
};
933933

934934
let (stop_sender, stop_receiver) = tokio::sync::watch::channel(());
@@ -981,7 +981,7 @@ fn seed_bytes_from_config(
981981
Some(EntropySourceConfig::SeedFile(seed_path)) => {
982982
Ok(io::utils::read_or_generate_seed_file(&seed_path, Arc::clone(&logger))
983983
.map_err(|_| BuildError::InvalidSeedFile)?)
984-
}
984+
},
985985
Some(EntropySourceConfig::Bip39Mnemonic { mnemonic, passphrase }) => match passphrase {
986986
Some(passphrase) => Ok(mnemonic.to_seed(passphrase)),
987987
None => Ok(mnemonic.to_seed("")),
@@ -991,6 +991,6 @@ fn seed_bytes_from_config(
991991
let seed_path = format!("{}/keys_seed", config.storage_dir_path);
992992
Ok(io::utils::read_or_generate_seed_file(&seed_path, Arc::clone(&logger))
993993
.map_err(|_| BuildError::InvalidSeedFile)?)
994-
}
994+
},
995995
}
996996
}

src/error.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl fmt::Display for Error {
7878
Self::NotRunning => write!(f, "Node is not running."),
7979
Self::OnchainTxCreationFailed => {
8080
write!(f, "On-chain transaction could not be created.")
81-
}
81+
},
8282
Self::ConnectionFailed => write!(f, "Network connection closed."),
8383
Self::InvoiceCreationFailed => write!(f, "Failed to create invoice."),
8484
Self::PaymentSendingFailed => write!(f, "Failed to send the given payment."),
@@ -89,7 +89,7 @@ impl fmt::Display for Error {
8989
Self::PersistenceFailed => write!(f, "Failed to persist data."),
9090
Self::FeerateEstimationUpdateFailed => {
9191
write!(f, "Failed to update fee rate estimates.")
92-
}
92+
},
9393
Self::WalletOperationFailed => write!(f, "Failed to conduct wallet operation."),
9494
Self::OnchainTxSigningFailed => write!(f, "Failed to sign given transaction."),
9595
Self::MessageSigningFailed => write!(f, "Failed to sign given message."),
@@ -109,16 +109,16 @@ impl fmt::Display for Error {
109109
Self::InvalidNetwork => write!(f, "The given network is invalid."),
110110
Self::DuplicatePayment => {
111111
write!(f, "A payment with the given hash has already been initiated.")
112-
}
112+
},
113113
Self::InsufficientFunds => {
114114
write!(f, "The available funds are insufficient to complete the given operation.")
115-
}
115+
},
116116
Self::LiquiditySourceUnavailable => {
117117
write!(f, "The given operation failed due to the required liquidity source being unavailable.")
118-
}
118+
},
119119
Self::LiquidityFeeTooHigh => {
120120
write!(f, "The given operation failed due to the LSP's required opening fee being too high.")
121-
}
121+
},
122122
}
123123
}
124124
}

0 commit comments

Comments
 (0)