Skip to content

Rustfmt chainmonitor.rs - #3847

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
joostjager:fmtskip-chainmonitor
Jun 17, 2025
Merged

Rustfmt chainmonitor.rs#3847
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
joostjager:fmtskip-chainmonitor

Conversation

@joostjager

Copy link
Copy Markdown
Contributor

I badly miss rustfmt for my changes in #3778.

The larger strategy for rustfmt is still being discussed (#3749, #3809), but getting this one with immediate benefit through would be great.

@ldk-reviews-bot

ldk-reviews-bot commented Jun 12, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Presumably we should just format all of chainmonitor.rs in one go? Its only 1200 lines and not very actively edited, why bother with an iterative approach?

@joostjager

Copy link
Copy Markdown
ContributorAuthor

Happy to do that. I just wanted to be conservative and only format the parts that I touch.

@joostjager
joostjagerforce-pushed the fmtskip-chainmonitor branch from df28592 to d0e501aCompareJune 12, 2025 17:52
@joostjager

Copy link
Copy Markdown
ContributorAuthor

Pushed full rustfmt'ed chainmonitor

@joostjagerjoostjager changed the title Rustfmt chainmonitor.rs selectivelyRustfmt chainmonitor.rsJun 12, 2025
valentinewallace
valentinewallace previously approved these changes Jun 12, 2025

@valentinewallacevalentinewallace 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.

I'm fine to do these in follow-up if you want to Just Land

Comment threadlightning/src/chain/chainmonitor.rs Outdated
Comment threadlightning/src/chain/chainmonitor.rs Outdated
Comment threadlightning/src/chain/chainmonitor.rs Outdated
Comment on lines +567 to +565
self.monitors
.read()
.unwrap()
.iter()

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.

nit: extract into var

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.

Based on CI failures, looks like you might have to extract only self.monitors.read().unwrap()

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Indeed. Done

match super::channelmonitor::process_events_body!(
self.monitors.read().unwrap().get(&channel_id).map(|m| &m.monitor), self.logger, ev, handler(ev).await) {
self.monitors.read().unwrap().get(&channel_id).map(|m| &m.monitor),
self.logger,
ev,
handler(ev).await
) {

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.

I'd prefer:

for channel_id in mons_to_process {letmut ev;let monitor = self.monitors.read().unwrap().get(&channel_id).map(|m| &m.monitor);let res = process_events_body!(monitor,self.logger, ev, handler(ev).await);match res {Ok(()) => {},Err(ReplayEvent()) => {self.event_notifier.notify();},}}

with importing process_events_body

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This starts to complain about borrow from a temporary value. Left as is, this is formatting only?

Comment threadlightning/src/chain/chainmonitor.rs Outdated
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Certainly if you don't want to bother cleaning things up we can just land a subset that doesn't need it and come back to it later, I was just suggesting it probably wasn't much effort to clean up as we went given the file's size.

@joostjager

Copy link
Copy Markdown
ContributorAuthor

Right. Yes, the clean up is kind of subjective, so wanted to avoid that. But will now go with @valentinewallace's suggestions above.

valentinewallace
valentinewallace previously approved these changes Jun 12, 2025
@joostjager

Copy link
Copy Markdown
ContributorAuthor

Rebased

@joostjager
joostjagerforce-pushed the fmtskip-chainmonitor branch from 449591a to 3242b93CompareJune 13, 2025 14:07
@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@tnull
tnull requested review from TheBlueMatt and removed request for tnullJune 16, 2025 08:14

@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.

Gonna go ahead and land but will clean things up a bit more in a followup.

#[cfg(not(c_bindings))]
assert!(nodes[1].chain_monitor.chain_monitor.list_pending_monitor_updates().get(&channel_id)
.unwrap().contains(&next_update));
assert!(nodes[1]

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.

Probably
worth
making
this
less
vertical
:)

check_closed_event!(&nodes[2], 1, ClosureReason::CommitmentTxConfirmed, false,
[nodes[0].node.get_our_node_id()], 1000000);
let closure_reason = ClosureReason::CommitmentTxConfirmed;
let node_a_id = nodes[0].node.get_our_node_id();

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.

Probably worth making this change across the two functional tests, given it somewhat reduces cognitive load when reading tests.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@joostjager@ldk-reviews-bot@TheBlueMatt@valentinewallace