Skip to content

Rustfmt chainmonitor.rs #3847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

joostjager
Copy link
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
Copy link

ldk-reviews-bot commented Jun 12, 2025

👋 Thanks for assigning @valentinewallace 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
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
Contributor Author

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

@joostjager joostjager force-pushed the fmtskip-chainmonitor branch from df28592 to d0e501a Compare June 12, 2025 17:52
@joostjager
Copy link
Contributor Author

Pushed full rustfmt'ed chainmonitor

@joostjager joostjager changed the title Rustfmt chainmonitor.rs selectively Rustfmt chainmonitor.rs Jun 12, 2025
Copy link
Contributor

@valentinewallace valentinewallace left a comment

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 on lines 567 to 565
self.monitors
.read()
.unwrap()
.iter()
Copy link
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
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
Contributor Author

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
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 {
			let mut 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
Contributor Author

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?

@TheBlueMatt
Copy link
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
Contributor Author

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

@joostjager
Copy link
Contributor Author

Rebased

@joostjager joostjager force-pushed the fmtskip-chainmonitor branch from 449591a to 3242b93 Compare June 13, 2025 14:07
Sign up for free to 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