Skip to content

Commit e6dd91c

Browse files
authored
Merge pull request #131 from tnull/2024-02-align-rustfmt
Align `rustfmt.toml` with `rust-lightning`
2 parents 16bc6f4 + c7302c4 commit e6dd91c

File tree

7 files changed

+90
-83
lines changed

7 files changed

+90
-83
lines changed

rustfmt.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
hard_tabs = true # use tab characters for indentation, spaces for alignment
1+
use_small_heuristics = "Max"
2+
fn_params_layout = "Compressed"
3+
hard_tabs = true
24
use_field_init_shorthand = true
35
max_width = 100
4-
use_small_heuristics = "Max"
5-
fn_args_layout = "Compressed"
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/args.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
3232
Some(Err(_)) => {
3333
ldk_peer_port_set = false;
3434
9735
35-
}
35+
},
3636
None => {
3737
ldk_peer_port_set = false;
3838
9735
39-
}
39+
},
4040
};
4141

4242
let mut arg_idx = match ldk_peer_port_set {
@@ -49,7 +49,7 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
4949
Some("signet") => Network::Signet,
5050
Some(net) => {
5151
panic!("Unsupported network provided. Options are: `regtest`, `testnet`, and `signet`. Got {}", net);
52-
}
52+
},
5353
None => Network::Testnet,
5454
};
5555

@@ -78,7 +78,7 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
7878
let mut bytes = [0; 32];
7979
bytes[..s.len()].copy_from_slice(s.as_bytes());
8080
bytes
81-
}
81+
},
8282
None => [0; 32],
8383
};
8484

@@ -89,7 +89,7 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
8989
Ok(sa) => {
9090
ldk_announced_listen_addr.push(sa);
9191
arg_idx += 1;
92-
}
92+
},
9393
Err(_) => panic!("Failed to parse announced-listen-addr into a socket address"),
9494
},
9595
None => break,

src/cli.rs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub(crate) fn poll_for_user_input(
106106
Err(e) => {
107107
println!("{:?}", e.into_inner().unwrap());
108108
continue;
109-
}
109+
},
110110
};
111111

112112
let chan_amt_sat: Result<u64, _> = channel_value_sat.unwrap().parse();
@@ -136,7 +136,7 @@ pub(crate) fn poll_for_user_input(
136136
_ => {
137137
println!("ERROR: invalid boolean flag format. Valid formats: `--option`, `--option=true` `--option=false`");
138138
continue;
139-
}
139+
},
140140
}
141141
}
142142

@@ -155,7 +155,7 @@ pub(crate) fn poll_for_user_input(
155155
peer_pubkey_and_ip_addr,
156156
);
157157
}
158-
}
158+
},
159159
"sendpayment" => {
160160
let invoice_str = words.next();
161161
if invoice_str.is_none() {
@@ -170,7 +170,7 @@ pub(crate) fn poll_for_user_input(
170170
Err(e) => {
171171
println!("ERROR: couldn't parse amount_msat: {}", e);
172172
continue;
173-
}
173+
},
174174
};
175175
}
176176

@@ -184,7 +184,7 @@ pub(crate) fn poll_for_user_input(
184184
(amt, _) => {
185185
println!("ERROR: Cannot process non-Bitcoin-denominated offer value {:?}", amt);
186186
continue;
187-
}
187+
},
188188
};
189189
if user_provided_amt.is_some() && user_provided_amt != Some(amt_msat) {
190190
println!("Amount didn't match offer of {}msat", amt_msat);
@@ -244,37 +244,37 @@ pub(crate) fn poll_for_user_input(
244244
),
245245
Err(e) => {
246246
println!("ERROR: invalid invoice: {:?}", e);
247-
}
247+
},
248248
}
249249
}
250-
}
250+
},
251251
"keysend" => {
252252
let dest_pubkey = match words.next() {
253253
Some(dest) => match hex_utils::to_compressed_pubkey(dest) {
254254
Some(pk) => pk,
255255
None => {
256256
println!("ERROR: couldn't parse destination pubkey");
257257
continue;
258-
}
258+
},
259259
},
260260
None => {
261261
println!("ERROR: keysend requires a destination pubkey: `keysend <dest_pubkey> <amt_msat>`");
262262
continue;
263-
}
263+
},
264264
};
265265
let amt_msat_str = match words.next() {
266266
Some(amt) => amt,
267267
None => {
268268
println!("ERROR: keysend requires an amount in millisatoshis: `keysend <dest_pubkey> <amt_msat>`");
269269
continue;
270-
}
270+
},
271271
};
272272
let amt_msat: u64 = match amt_msat_str.parse() {
273273
Ok(amt) => amt,
274274
Err(e) => {
275275
println!("ERROR: couldn't parse amount_msat: {}", e);
276276
continue;
277-
}
277+
},
278278
};
279279
keysend(
280280
&channel_manager,
@@ -284,7 +284,7 @@ pub(crate) fn poll_for_user_input(
284284
&mut outbound_payments.lock().unwrap(),
285285
Arc::clone(&fs_store),
286286
);
287-
}
287+
},
288288
"getoffer" => {
289289
let offer_builder = channel_manager.create_offer_builder(String::new());
290290
if let Err(e) = offer_builder {
@@ -312,7 +312,7 @@ pub(crate) fn poll_for_user_input(
312312
// correspond with individual payments.
313313
println!("{}", offer.unwrap());
314314
}
315-
}
315+
},
316316
"getinvoice" => {
317317
let amt_str = words.next();
318318
if amt_str.is_none() {
@@ -351,7 +351,7 @@ pub(crate) fn poll_for_user_input(
351351
fs_store
352352
.write("", "", INBOUND_PAYMENTS_FNAME, &inbound_payments.encode())
353353
.unwrap();
354-
}
354+
},
355355
"connectpeer" => {
356356
let peer_pubkey_and_ip_addr = words.next();
357357
if peer_pubkey_and_ip_addr.is_none() {
@@ -364,7 +364,7 @@ pub(crate) fn poll_for_user_input(
364364
Err(e) => {
365365
println!("{:?}", e.into_inner().unwrap());
366366
continue;
367-
}
367+
},
368368
};
369369
if tokio::runtime::Handle::current()
370370
.block_on(connect_peer_if_necessary(
@@ -376,7 +376,7 @@ pub(crate) fn poll_for_user_input(
376376
{
377377
println!("SUCCESS: connected to peer {}", pubkey);
378378
}
379-
}
379+
},
380380
"disconnectpeer" => {
381381
let peer_pubkey = words.next();
382382
if peer_pubkey.is_none() {
@@ -390,7 +390,7 @@ pub(crate) fn poll_for_user_input(
390390
Err(e) => {
391391
println!("ERROR: {}", e.to_string());
392392
continue;
393-
}
393+
},
394394
};
395395

396396
if do_disconnect_peer(
@@ -402,7 +402,7 @@ pub(crate) fn poll_for_user_input(
402402
{
403403
println!("SUCCESS: disconnected from peer {}", peer_pubkey);
404404
}
405-
}
405+
},
406406
"listchannels" => list_channels(&channel_manager, &network_graph),
407407
"listpayments" => list_payments(
408408
&inbound_payments.lock().unwrap(),
@@ -432,18 +432,18 @@ pub(crate) fn poll_for_user_input(
432432
None => {
433433
println!("ERROR: couldn't parse peer_pubkey");
434434
continue;
435-
}
435+
},
436436
};
437437
let peer_pubkey = match PublicKey::from_slice(&peer_pubkey_vec) {
438438
Ok(peer_pubkey) => peer_pubkey,
439439
Err(_) => {
440440
println!("ERROR: couldn't parse peer_pubkey");
441441
continue;
442-
}
442+
},
443443
};
444444

445445
close_channel(channel_id, peer_pubkey, channel_manager.clone());
446-
}
446+
},
447447
"forceclosechannel" => {
448448
let channel_id_str = words.next();
449449
if channel_id_str.is_none() {
@@ -468,18 +468,18 @@ pub(crate) fn poll_for_user_input(
468468
None => {
469469
println!("ERROR: couldn't parse peer_pubkey");
470470
continue;
471-
}
471+
},
472472
};
473473
let peer_pubkey = match PublicKey::from_slice(&peer_pubkey_vec) {
474474
Ok(peer_pubkey) => peer_pubkey,
475475
Err(_) => {
476476
println!("ERROR: couldn't parse peer_pubkey");
477477
continue;
478-
}
478+
},
479479
};
480480

481481
force_close_channel(channel_id, peer_pubkey, channel_manager.clone());
482-
}
482+
},
483483
"nodeinfo" => node_info(&channel_manager, &peer_manager),
484484
"listpeers" => list_peers(peer_manager.clone()),
485485
"signmessage" => {
@@ -495,7 +495,7 @@ pub(crate) fn poll_for_user_input(
495495
&keys_manager.get_node_secret_key()
496496
)
497497
);
498-
}
498+
},
499499
"sendonionmessage" => {
500500
let path_pks_str = words.next();
501501
if path_pks_str.is_none() {
@@ -513,15 +513,15 @@ pub(crate) fn poll_for_user_input(
513513
println!("ERROR: couldn't parse peer_pubkey");
514514
errored = true;
515515
break;
516-
}
516+
},
517517
};
518518
let node_pubkey = match PublicKey::from_slice(&node_pubkey_vec) {
519519
Ok(peer_pubkey) => peer_pubkey,
520520
Err(_) => {
521521
println!("ERROR: couldn't parse peer_pubkey");
522522
errored = true;
523523
break;
524-
}
524+
},
525525
};
526526
intermediate_nodes.push(node_pubkey);
527527
}
@@ -533,14 +533,14 @@ pub(crate) fn poll_for_user_input(
533533
_ => {
534534
println!("Need an integral message type above 64");
535535
continue;
536-
}
536+
},
537537
};
538538
let data = match words.next().map(|s| hex_utils::to_vec(s)) {
539539
Some(Some(data)) => data,
540540
_ => {
541541
println!("Need a hex data string");
542542
continue;
543-
}
543+
},
544544
};
545545
let destination = Destination::Node(intermediate_nodes.pop().unwrap());
546546
match onion_messenger.send_onion_message(
@@ -550,10 +550,10 @@ pub(crate) fn poll_for_user_input(
550550
) {
551551
Ok(success) => {
552552
println!("SUCCESS: forwarded onion message to first hop {:?}", success)
553-
}
553+
},
554554
Err(e) => println!("ERROR: failed to send onion message: {:?}", e),
555555
}
556-
}
556+
},
557557
"quit" | "exit" => break,
558558
_ => println!("Unknown command. See `\"help\" for available commands."),
559559
}
@@ -729,7 +729,7 @@ pub(crate) async fn do_connect_peer(
729729
return Ok(());
730730
}
731731
}
732-
}
732+
},
733733
None => Err(()),
734734
}
735735
}
@@ -779,11 +779,11 @@ fn open_channel(
779779
Ok(_) => {
780780
println!("EVENT: initiated channel with peer {}. ", peer_pubkey);
781781
return Ok(());
782-
}
782+
},
783783
Err(e) => {
784784
println!("ERROR: failed to open channel: {:?}", e);
785785
return Err(());
786-
}
786+
},
787787
}
788788
}
789789

@@ -821,7 +821,7 @@ fn send_payment(
821821
println!("Failed to parse invoice: {:?}", e);
822822
print!("> ");
823823
return;
824-
}
824+
},
825825
};
826826
outbound_payments.payments.insert(
827827
payment_id,
@@ -846,13 +846,13 @@ fn send_payment(
846846
let amt_msat = invoice.amount_milli_satoshis().unwrap();
847847
println!("EVENT: initiated sending {} msats to {}", amt_msat, payee_pubkey);
848848
print!("> ");
849-
}
849+
},
850850
Err(e) => {
851851
println!("ERROR: failed to send payment: {:?}", e);
852852
print!("> ");
853853
outbound_payments.payments.get_mut(&payment_id).unwrap().status = HTLCStatus::Failed;
854854
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
855-
}
855+
},
856856
};
857857
}
858858

@@ -887,13 +887,13 @@ fn keysend<E: EntropySource>(
887887
Ok(_payment_hash) => {
888888
println!("EVENT: initiated sending {} msats to {}", amt_msat, payee_pubkey);
889889
print!("> ");
890-
}
890+
},
891891
Err(e) => {
892892
println!("ERROR: failed to send payment: {:?}", e);
893893
print!("> ");
894894
outbound_payments.payments.get_mut(&payment_id).unwrap().status = HTLCStatus::Failed;
895895
fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
896-
}
896+
},
897897
};
898898
}
899899

@@ -921,11 +921,11 @@ fn get_invoice(
921921
Ok(inv) => {
922922
println!("SUCCESS: generated invoice: {}", inv);
923923
inv
924-
}
924+
},
925925
Err(e) => {
926926
println!("ERROR: failed to create invoice: {:?}", e);
927927
return;
928-
}
928+
},
929929
};
930930

931931
let payment_hash = PaymentHash(invoice.payment_hash().to_byte_array());

0 commit comments

Comments
 (0)