Skip to content

Run rustfmt on lightning-block-sync - #3136

Merged
TheBlueMatt merged 14 commits into
lightningdevkit:mainfrom
tnull:2024-06-rustfmt-lightning-block-sync
Jul 17, 2024
Merged

Run rustfmt on lightning-block-sync#3136
TheBlueMatt merged 14 commits into
lightningdevkit:mainfrom
tnull:2024-06-rustfmt-lightning-block-sync

Conversation

@tnull

Copy link
Copy Markdown
Contributor

.. this seems like another trivial one.

While we're here, we also drop lightning-custom-message/src/lib.rs from the excluded files, as it doesn't require reformatting.

@tnull
tnull requested review from TheBlueMatt and jkczyzJune 20, 2024 09:12
dunxen
dunxen previously approved these changes Jun 20, 2024

@dunxendunxen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Ran cargo fmt --package lightning-block-sync on my side and there were no differences to this PR.

Comment threadlightning-block-sync/src/convert.rs Outdated
Comment threadlightning-block-sync/src/convert.rs Outdated
Comment threadlightning-block-sync/src/gossip.rs Outdated
Comment threadlightning-block-sync/src/test_utils.rs
@tnull
tnullforce-pushed the 2024-06-rustfmt-lightning-block-sync branch from e548b89 to e337aadCompareJuly 1, 2024 09:20
@codecov-commenter

codecov-commenter commented Jul 1, 2024

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 74.29194% with 118 lines in your changes missing coverage. Please review.

Project coverage is 89.76%. Comparing base (dd5d297) to head (12e4efa).

FilesPatch %Lines
lightning-block-sync/src/gossip.rs0.00%25 Missing ⚠️
lightning-block-sync/src/convert.rs84.66%13 Missing and 10 partials ⚠️
lightning-block-sync/src/rest.rs29.16%15 Missing and 2 partials ⚠️
lightning-block-sync/src/rpc.rs55.26%14 Missing and 3 partials ⚠️
lightning-block-sync/src/http.rs86.31%12 Missing and 1 partial ⚠️
lightning-block-sync/src/init.rs65.51%8 Missing and 2 partials ⚠️
lightning-block-sync/src/poll.rs71.87%5 Missing and 4 partials ⚠️
lightning-block-sync/src/lib.rs90.90%3 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@ Coverage Diff @@## main #3136 +/- ##
==========================================
- Coverage 89.82% 89.76% -0.06% 
==========================================
Files 121 121 Lines 100404 100500 +96 Branches 100404 100500 +96 ==========================================
+ Hits 90187 90217 +30 - Misses 7553 7605 +52 - Partials 2664 2678 +14 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

dunxen
dunxen previously approved these changes Jul 1, 2024
@tnull
tnullforce-pushed the 2024-06-rustfmt-lightning-block-sync branch from e337aad to de41b4dCompareJuly 9, 2024 08:05
@tnull

tnull commented Jul 9, 2024

Copy link
Copy Markdown
ContributorAuthor

Addressed outstanding feedback.

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Feel free to squash.

@tnull
tnullforce-pushed the 2024-06-rustfmt-lightning-block-sync branch from de41b4d to 1494f3bCompareJuly 15, 2024 06:48
@tnull

Copy link
Copy Markdown
ContributorAuthor

Feel free to squash.

Squashed without further changes:

> git diff-tree -U2 de41b4d03 1494f3bb4>

@tnull
tnullforce-pushed the 2024-06-rustfmt-lightning-block-sync branch from 1494f3b to 12e4efaCompareJuly 15, 2024 11:57
@tnull

Copy link
Copy Markdown
ContributorAuthor

Also added a commit dropping lightning-background-processor/src/lib.rs from the exclusion list, which somehow snuck back in even though it was formatted in #3138.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, diff since @dunxen's ack were pretty simple code cleanups, so just gonna land:

$ git range-diff 3ccf06416091e107f443ee92027501105c48054b...e337aadf10656aa97feb7206bfb18b3233e6ef88 dd5d297d641facad24518cf2668cf1f38caf7dbc...12e4efa0ffd3b47a5d5952d1de83490a8f1b58b0
1: 6cc998a4e ! 1: 2f9bdc729 Prepare `convert.rs`
@@ lightning-block-sync/src/convert.rs: pub(crate) struct GetUtxosResponse {
- fn try_into(self) -> std::io::Result<GetUtxosResponse> {
+ fn try_into(self) -> io::Result<GetUtxosResponse> {
-+ let obj_err = io::Error::new(io::ErrorKind::InvalidData, "expected an object");
-+ let bitmap_err = io::Error::new(io::ErrorKind::InvalidData, "missing bitmap field");
-+ let bitstr_err = io::Error::new(io::ErrorKind::InvalidData, "bitmap should be an str");
++ let obj_err = || io::Error::new(io::ErrorKind::InvalidData, "expected an object");
++ let bitmap_err = || io::Error::new(io::ErrorKind::InvalidData, "missing bitmap field");
++ let bitstr_err = || io::Error::new(io::ErrorKind::InvalidData, "bitmap should be an str");
let bitmap_str =
- self.0.as_object().ok_or(std::io::Error::new(std::io::ErrorKind::InvalidData, "expected an object"))?
- .get("bitmap").ok_or(std::io::Error::new(std::io::ErrorKind::InvalidData, "missing bitmap field"))?
- .as_str().ok_or(std::io::Error::new(std::io::ErrorKind::InvalidData, "bitmap should be an str"))?;
-+ self.0.as_object().ok_or(obj_err)?
-+ .get("bitmap").ok_or(bitmap_err)?
-+ .as_str().ok_or(bitstr_err)?;
++ self.0.as_object().ok_or_else(obj_err)?
++ .get("bitmap").ok_or_else(bitmap_err)?
++ .as_str().ok_or_else(bitstr_err)?;
let mut hit_bitmap_nonempty = false;
for c in bitmap_str.chars() {
if c < '0' || c > '9' {
2: 38ff2dbf0 ! 2: 20669aeb7 `rustfmt`: Run on `lightning-block-sync/src/convert.rs`
@@ lightning-block-sync/src/convert.rs: impl TryInto<BlockHash> for JsonResponse {
#[cfg(feature = "rest-client")]
@@ lightning-block-sync/src/convert.rs: impl TryInto<GetUtxosResponse> for JsonResponse {
- let obj_err = io::Error::new(io::ErrorKind::InvalidData, "expected an object");
- let bitmap_err = io::Error::new(io::ErrorKind::InvalidData, "missing bitmap field");
- let bitstr_err = io::Error::new(io::ErrorKind::InvalidData, "bitmap should be an str");
+ let obj_err = || io::Error::new(io::ErrorKind::InvalidData, "expected an object");
+ let bitmap_err = || io::Error::new(io::ErrorKind::InvalidData, "missing bitmap field");
+ let bitstr_err = || io::Error::new(io::ErrorKind::InvalidData, "bitmap should be an str");
- let bitmap_str =
-- self.0.as_object().ok_or(obj_err)?
-- .get("bitmap").ok_or(bitmap_err)?
-- .as_str().ok_or(bitstr_err)?;
+- self.0.as_object().ok_or_else(obj_err)?
+- .get("bitmap").ok_or_else(bitmap_err)?
+- .as_str().ok_or_else(bitstr_err)?;
- let mut hit_bitmap_nonempty = false;
- for c in bitmap_str.chars() {
- if c < '0' || c > '9' {
@@ lightning-block-sync/src/convert.rs: impl TryInto<GetUtxosResponse> for JsonResp
+ let bitmap_str = self
+ .0
+ .as_object()
-+ .ok_or(obj_err)?
++ .ok_or_else(obj_err)?
+ .get("bitmap")
-+ .ok_or(bitmap_err)?
++ .ok_or_else(bitmap_err)?
+ .as_str()
-+ .ok_or(bitstr_err)?;
++ .ok_or_else(bitstr_err)?;
+ let mut hit_bitmap_nonempty = false;
+ for c in bitmap_str.chars() {
+ if c < '0' || c > '9' {
-: --------- > 3: 16614963c Prepare `lightning-block-sync/src/gossip.rs`
3: 76125a04d ! 4: 8975979fc `rustfmt`: Run on `lightning-block-sync/src/gossip.rs`
@@ lightning-block-sync/src/gossip.rs: impl<S: FutureSpawner,
let transaction_index = ((short_channel_id >> 2 * 8) & 0xffffff) as u32;
@@ lightning-block-sync/src/gossip.rs: impl<S: FutureSpawner,
- let (outpoint, output);
-
-- 'tx_found: loop { // Used as a simple goto
-+ 'tx_found: loop {
-+ // Used as a simple goto
+ 'tx_found: loop {
macro_rules! process_block {
- ($block: expr) => { {
+ ($block: expr) => {{
4: 3268adbc3 = 5: 310ad9a0e `rustfmt`: Run on `lightning-block-sync/src/http.rs`
5: ee65a9bf2 = 6: fb57e0405 `rustfmt`: Run on `lightning-block-sync/src/init.rs`
6: c53fb75a8 = 7: 26cacb60b `rustfmt`: Run on `lightning-block-sync/src/poll.rs`
7: decab2fec = 8: 634821a95 `rustfmt`: Run on `lightning-block-sync/src/rest.rs`
8: f2b11a149 = 9: 3ef5f18eb `rustfmt`: Run on `lightning-block-sync/src/rpc.rs`
9: d478ade42 = 10: ad7021ae3 `rustfmt`: Run on `lightning-block-sync/src/test_utils.rs`
10: 92e4035a5 = 11: 43abde8d7 `rustfmt`: Run on `lightning-block-sync/src/utils.rs`
11: 623ad51ce = 12: 9c2f4cb6c `rustfmt`: Run on `lightning-block-sync/src/lib.rs`
12: e337aadf1 = 13: 5e163da8d `rustfmt`: Drop `lightning-custom-message/src/lib.rs` from excluded
-: --------- > 14: 12e4efa0f Drop `lightning-background-processor/src/lib.rs` from exclusion list

@TheBlueMatt
TheBlueMatt merged commit c3c909b into lightningdevkit:mainJul 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@tnull@codecov-commenter@TheBlueMatt@dunxen