Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add testmempoolaccept endpoint #81
Add testmempoolaccept endpoint #81
Changes from all commits
055ac9f
946ea71
569af75
f7385ce
ac32e4b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f32::EPSILON (the smallest difference representable above 1.0) works out to about 11 sats when we consider 1.0 to be 1 BTC. So it can only really reliably show 7 decimal places.
Which I guess is fine if we consider 0.00001 BTC /kvB (5 decimal places) to be the minimum. (1 sat per vB) In which case showing 8 decimal places is pointless.
I wonder what the type is in Core. Might be worth it to use that, and round it to 8 if we use f64 and 7 if we use f32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://doc.rust-lang.org/std/primitive.f32.html#associatedconstant.EPSILON
0.00000011920929
is the smallest increment of f32.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://doc.rust-lang.org/std/primitive.f64.html#associatedconstant.EPSILON
0.00000000000000022204460492503131
is smallest for f64There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could always just accept the sane sat/vB instead of BTC/kvB, and just slide the decimal place 5 to the left. lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testmempoolaccept in Core throws an error if you give it too many decimal places (e.g. from floating point rounding errors), so it needs to be truncated to something.
I picked 8.d.p out of habit, but yeah I'll check what Core's bounds actually are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it turns out 8.d.p is actually exactly Core's limit (it's parsed as a fixed point number with scale 8):
https://github.com/bitcoin/bitcoin/blob/c1223188e0a5fb11c3a1b9224511a49dc2f848ed/src/rpc/util.cpp#L82-L87
https://github.com/bitcoin/bitcoin/blob/c1223188e0a5fb11c3a1b9224511a49dc2f848ed/src/rpc/util.h#L105
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you should use f64 so that 8 decimal points can be properly represented without truncating.