Skip to content
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

amount_sat/amount_msat audit results #3904

Merged

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Aug 5, 2020

In #3902 @niftynei added a new helper: I took the opportunity to audit all our amount /* Raw comments and created a few new intuitive helpers. In particular, importing amounts isn't really an issue, though exporting them is still something I prefer people to look at carefully.

Changelog-None

niftynei and others added 4 commits August 5, 2020 12:45
Generally, importing amounts needn't be checked, and it cuts down on
the warnings we get.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
It's not all that rare to do these operations, and requiring annotations
for it is a little painful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Copy link
Collaborator

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

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

ACK 4c2dcc7

@@ -401,22 +401,20 @@ bool amount_msat_to_u32(struct amount_msat msat, u32 *millisatoshis)
return true;
}

void amount_msat_from_u64(struct amount_msat *msat, u64 millisatoshis)
struct amount_msat amount_msat(u64 millisatoshis)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this better than the void foo(out* out, int input) style. This is in fact what I thought AMOUNT_SAT/AMOUNT_MSAT did back when they were introduced, and was disappointed to learn they were just constexpr, boo.

The compiler might be able to optimize these better if we static inline these in the headers.

@rustyrussell rustyrussell merged commit fa829f2 into ElementsProject:master Aug 6, 2020
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.

3 participants