Skip to content

Commit ba4ea19

Browse files
committed
Switch to nightly rustfmt
1 parent e4bb615 commit ba4ea19

File tree

26 files changed

+492
-237
lines changed

26 files changed

+492
-237
lines changed

.github/workflows/rust.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
- name: Install Rust ${{ matrix.toolchain }} toolchain
3939
run: |
4040
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
41-
rustup override set ${{ matrix.toolchain }}
4241
- name: Check formatting on Rust ${{ matrix.toolchain }}
4342
if: matrix.check-fmt
4443
run: rustup component add rustfmt && cargo fmt --all -- --check

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "nightly-2025-10-08"
3+
components = [ "rustfmt" ]
4+
profile = "minimal"

rustfmt.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ hard_tabs = true
44
use_field_init_shorthand = true
55
max_width = 100
66
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"
13-
# UNSTABLE: reorder_imports = true
14-
# UNSTABLE: imports_granularity = "Module"
7+
format_code_in_doc_comments = true
8+
overflow_delimited_expr = true
9+
comment_width = 100
10+
format_macro_matchers = true
11+
format_strings = true
12+
group_imports = "StdExternalCrate"
13+
reorder_imports = true
14+
imports_granularity = "Module"

src/builder.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,9 @@ impl NodeBuilder {
627627
derive_xprv(config, &seed_bytes, VSS_HARDENED_CHILD_INDEX, Arc::clone(&logger))?;
628628

629629
let lnurl_auth_xprv = vss_xprv
630-
.derive_priv(
631-
&Secp256k1::new(),
632-
&[ChildNumber::Hardened { index: VSS_LNURL_AUTH_HARDENED_CHILD_INDEX }],
633-
)
630+
.derive_priv(&Secp256k1::new(), &[ChildNumber::Hardened {
631+
index: VSS_LNURL_AUTH_HARDENED_CHILD_INDEX,
632+
}])
634633
.map_err(|e| {
635634
log_error!(logger, "Failed to derive VSS secret: {}", e);
636635
BuildError::KVStoreSetupFailed
@@ -1116,7 +1115,12 @@ fn build_with_store_internal(
11161115

11171116
if let Err(err) = may_announce_channel(&config) {
11181117
if config.announcement_addresses.is_some() {
1119-
log_error!(logger, "Announcement addresses were set but some required configuration options for node announcement are missing: {}", err);
1118+
log_error!(
1119+
logger,
1120+
"Announcement addresses were set but some required configuration options for node \
1121+
announcement are missing: {}",
1122+
err
1123+
);
11201124
let build_error = if matches!(err, AnnounceError::MissingNodeAlias) {
11211125
BuildError::InvalidNodeAlias
11221126
} else {
@@ -1126,7 +1130,12 @@ fn build_with_store_internal(
11261130
}
11271131

11281132
if config.node_alias.is_some() {
1129-
log_error!(logger, "Node alias was set but some required configuration options for node announcement are missing: {}", err);
1133+
log_error!(
1134+
logger,
1135+
"Node alias was set but some required configuration options for node announcement \
1136+
are missing: {}",
1137+
err
1138+
);
11301139
return Err(BuildError::InvalidListeningAddresses);
11311140
}
11321141
}

src/chain/bitcoind.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,22 @@ impl BitcoindChainSource {
221221
log_error!(self.logger, "Failed to synchronize chain listeners: {:?}", e);
222222
if e.kind() == BlockSourceErrorKind::Transient {
223223
log_info!(
224-
self.logger,
225-
"Transient error syncing chain listeners: {:?}. Retrying in {} seconds.",
226-
e,
227-
backoff
228-
);
224+
self.logger,
225+
"Transient error syncing chain listeners: {:?}. Retrying in {} \
226+
seconds.",
227+
e,
228+
backoff
229+
);
229230
tokio::time::sleep(Duration::from_secs(backoff)).await;
230231
backoff = std::cmp::min(backoff * 2, MAX_BACKOFF_SECS);
231232
} else {
232233
log_error!(
233-
self.logger,
234-
"Persistent error syncing chain listeners: {:?}. Retrying in {} seconds.",
235-
e,
236-
MAX_BACKOFF_SECS
237-
);
234+
self.logger,
235+
"Persistent error syncing chain listeners: {:?}. Retrying in {} \
236+
seconds.",
237+
e,
238+
MAX_BACKOFF_SECS
239+
);
238240
tokio::time::sleep(Duration::from_secs(MAX_BACKOFF_SECS)).await;
239241
}
240242
},
@@ -415,7 +417,7 @@ impl BitcoindChainSource {
415417

416418
pub(super) async fn update_fee_rate_estimates(&self) -> Result<(), Error> {
417419
macro_rules! get_fee_rate_update {
418-
($estimation_fut: expr) => {{
420+
($estimation_fut:expr) => {{
419421
let update_res = tokio::time::timeout(
420422
Duration::from_secs(FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS),
421423
$estimation_fut,
@@ -475,10 +477,11 @@ impl BitcoindChainSource {
475477
// On regtest/signet we just fall back to the usual 1 sat/vb == 250
476478
// sat/kwu default.
477479
log_error!(
478-
self.logger,
479-
"Failed to retrieve fee rate estimates: {}. Falling back to default of 1 sat/vb.",
480-
e,
481-
);
480+
self.logger,
481+
"Failed to retrieve fee rate estimates: {}. Falling back to default of 1 \
482+
sat/vb.",
483+
e,
484+
);
482485
FeeRate::from_sat_per_kwu(250)
483486
},
484487
(Err(e), _) => {
@@ -701,10 +704,10 @@ impl BitcoindClient {
701704
let num_blocks_json = serde_json::json!(num_blocks);
702705
let estimation_mode_json = serde_json::json!(estimation_mode);
703706
rpc_client
704-
.call_method::<FeeResponse>(
705-
"estimatesmartfee",
706-
&[num_blocks_json, estimation_mode_json],
707-
)
707+
.call_method::<FeeResponse>("estimatesmartfee", &[
708+
num_blocks_json,
709+
estimation_mode_json,
710+
])
708711
.await
709712
.map(|resp| resp.0)
710713
}

src/chain/electrum.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,11 +604,15 @@ impl ElectrumRuntimeClient {
604604
&& self.config.network == Network::Bitcoin
605605
{
606606
// Ensure we fail if we didn't receive all estimates.
607-
debug_assert!(false,
608-
"Electrum server didn't return all expected results. This is disallowed on Mainnet."
607+
debug_assert!(
608+
false,
609+
"Electrum server didn't return all expected results. This is disallowed on \
610+
Mainnet."
609611
);
610-
log_error!(self.logger,
611-
"Failed to retrieve fee rate estimates: Electrum server didn't return all expected results. This is disallowed on Mainnet."
612+
log_error!(
613+
self.logger,
614+
"Failed to retrieve fee rate estimates: Electrum server didn't return all \
615+
expected results. This is disallowed on Mainnet."
612616
);
613617
return Err(Error::FeerateEstimationUpdateFailed);
614618
}

src/chain/esplora.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl EsploraChainSource {
108108
self.node_metrics.read().unwrap().latest_onchain_wallet_sync_timestamp.is_some();
109109

110110
macro_rules! get_and_apply_wallet_update {
111-
($sync_future: expr) => {{
111+
($sync_future:expr) => {{
112112
let now = Instant::now();
113113
match $sync_future.await {
114114
Ok(res) => match res {
@@ -124,16 +124,18 @@ impl EsploraChainSource {
124124
.duration_since(UNIX_EPOCH)
125125
.ok()
126126
.map(|d| d.as_secs());
127-
{
128-
let mut locked_node_metrics = self.node_metrics.write().unwrap();
129-
locked_node_metrics.latest_onchain_wallet_sync_timestamp = unix_time_secs_opt;
130-
write_node_metrics(
131-
&*locked_node_metrics,
132-
Arc::clone(&self.kv_store),
133-
Arc::clone(&self.logger)
134-
)?;
135-
}
136-
Ok(())
127+
{
128+
let mut locked_node_metrics =
129+
self.node_metrics.write().unwrap();
130+
locked_node_metrics.latest_onchain_wallet_sync_timestamp =
131+
unix_time_secs_opt;
132+
write_node_metrics(
133+
&*locked_node_metrics,
134+
Arc::clone(&self.kv_store),
135+
Arc::clone(&self.logger),
136+
)?;
137+
}
138+
Ok(())
137139
},
138140
Err(e) => Err(e),
139141
},
@@ -178,7 +180,7 @@ impl EsploraChainSource {
178180
Err(Error::WalletOperationTimeout)
179181
},
180182
}
181-
}}
183+
}};
182184
}
183185

184186
if incremental_sync {
@@ -307,9 +309,10 @@ impl EsploraChainSource {
307309
if estimates.is_empty() && self.config.network == Network::Bitcoin {
308310
// Ensure we fail if we didn't receive any estimates.
309311
log_error!(
310-
self.logger,
311-
"Failed to retrieve fee rate estimates: empty fee estimates are dissallowed on Mainnet.",
312-
);
312+
self.logger,
313+
"Failed to retrieve fee rate estimates: empty fee estimates are dissallowed on \
314+
Mainnet.",
315+
);
313316
return Err(Error::FeerateEstimationUpdateFailed);
314317
}
315318

src/chain/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ impl ChainSource {
245245
// Background syncing is disabled
246246
log_info!(
247247
self.logger,
248-
"Background syncing is disabled. Manual syncing required for onchain wallet, lightning wallet, and fee rate updates.",
248+
"Background syncing is disabled. Manual syncing required for onchain \
249+
wallet, lightning wallet, and fee rate updates.",
249250
);
250251
return;
251252
}
@@ -267,7 +268,8 @@ impl ChainSource {
267268
// Background syncing is disabled
268269
log_info!(
269270
self.logger,
270-
"Background syncing is disabled. Manual syncing required for onchain wallet, lightning wallet, and fee rate updates.",
271+
"Background syncing is disabled. Manual syncing required for onchain \
272+
wallet, lightning wallet, and fee rate updates.",
271273
);
272274
return;
273275
}

src/error.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,18 @@ impl fmt::Display for Error {
193193
write!(f, "The provided offer was denonminated in an unsupported currency.")
194194
},
195195
Self::LiquiditySourceUnavailable => {
196-
write!(f, "The given operation failed due to the required liquidity source being unavailable.")
196+
write!(
197+
f,
198+
"The given operation failed due to the required liquidity source being \
199+
unavailable."
200+
)
197201
},
198202
Self::LiquidityFeeTooHigh => {
199-
write!(f, "The given operation failed due to the LSP's required opening fee being too high.")
203+
write!(
204+
f,
205+
"The given operation failed due to the LSP's required opening fee being too \
206+
high."
207+
)
200208
},
201209
Self::InvalidBlindedPaths => write!(f, "The given blinded paths are invalid."),
202210
Self::AsyncPaymentServicesDisabled => {

0 commit comments

Comments
 (0)