Implemented as per sipa's suggestion. Was meant to be merged via #6191 had it not be closed out a little too expeditiously. It's not perfect, but it's good enough.
Rename MAX_MONEY to AMOUNT_OVERFLOW_PROTECTION_THRESHOLD #6197
pull ghost wants to merge 1 commits into bitcoin:master from changing 7 files +16 −15-
ghost commented at 10:25 PM on May 27, 2015: none
-
sipa commented at 3:40 AM on May 28, 2015: member
Either is fine for me.
-
paveljanik commented at 5:40 AM on May 28, 2015: contributor
I also prefer Peter's comment over changing so many files.
-
maaku commented at 10:09 AM on May 28, 2015: contributor
The diff is only 12 lines over 7 files. Concept ACK, although it's currently failing Travis...
-
petertodd commented at 11:00 AM on May 28, 2015: contributor
Keep in mind that this constant is already named "MAX_MONEY" in many other 3rd party libraries, including bitcoinj, libbitcoin, python-bitcoinlib, etc. etc.
Renaming it is needlessly confusing.
-
petertodd commented at 7:06 PM on May 28, 2015: contributor
re: other implementations, that includes a fair number of Bitcoin clients as well. For example: https://github.com/vinumeris/lighthouse/blob/63b35ca3abc6ec18e346d9eeb56462b5f35c6066/client/src/main/java/lighthouse/utils/BitcoinValue.java
Also, it's good practice when you do things like take others' commits and add them to your own pull-reqs to credit appropriately. git cherry-pick is useful for that purpose.
-
ghost commented at 12:51 AM on May 29, 2015: none
@petertodd The more reason to correct it, and disrupt the ripple effect — no pun intended. The credit for the comment is yours, of course, but it could not be adopted verbatim, due to the const reference. I expect the two to be squashed anyhow.
-
laanwj commented at 10:30 AM on May 29, 2015: member
Either is fine with me too, although I have a slight preference for @petertodd 's solution due to lower impact. The constant is an upper bound on the possible coins, not the limit value of the cumulative reward function, so
MAX_xxxis sort of appropriate, the new name is a bit awkward and pedantic (but correct). Getting rid of the wordmoneyon the other hand is nice... -
petertodd commented at 12:06 PM on May 29, 2015: contributor
The word "money" doesn't bother me at all, but I'd there was consensus to change it, the phrase MAX_VALUE is much less awkward. "Max upper bound on the value you will see in any one place; used as a (consensus critical) sanity check in various places, e.g. the total sum out of transaction txout"
-
laanwj commented at 12:30 PM on May 29, 2015: member
Heh. We had that discussion once; MAX_VALUE and MAX_AMOUNT are too generic, could refer to everything, and could easily collide with other things. At least this long awkward constant name is impossible to mix up.
-
davecgh commented at 2:27 PM on May 29, 2015: contributor
I prefer the less invasive approach of adding a comment as well. The name
MAX_XYZis appropriate given how the constant is used. Also, I find the name in this pr awkward and way long at 36 characters, which is completely contrary to elegant for me. -
ghost commented at 4:42 PM on May 29, 2015: none
@davecgh I'd rather view invasiveness (12 lines over 7 files, as maaku pointed out) as no excuse for canonizing bugs, and that's what MAX_MONEY is. sipa's const and petertodd's comment are an imperfect step, but one in the right direction. As a matter of fact, sipa's choice of words was masterful here, and may survive the test of time as the const gets refactored as its taint inevitably will.
-
maaku commented at 6:28 PM on May 30, 2015: contributor
Tested ACK.
-
paveljanik commented at 11:21 AM on May 31, 2015: contributor
@21E14 BTW,
MoneyRange()is OK for you? -
maaku commented at 9:37 AM on June 1, 2015: contributor
Needs rebase
-
ghost commented at 2:29 AM on June 2, 2015: none
Rebased.
-
Rename MAX_MONEY to AMOUNT_OVERFLOW_PROTECTION_THRESHOLD for improved semantics c547b48c01
-
laanwj commented at 3:18 PM on June 12, 2015: member
The new name really irks me. @petertodd's comment update is good enough, everyone that wonders what the constant does can now easily look it up, without having to embed it all into the identifier. Closing.
- laanwj closed this on Jun 12, 2015
- MarcoFalke locked this on Sep 8, 2021