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
  1. ghost commented at 10:25 PM on May 27, 2015: none

    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.

  2. petertodd commented at 1:05 AM on May 28, 2015: contributor

    NAK, see #6198, less invasive.

  3. sipa commented at 3:40 AM on May 28, 2015: member

    Either is fine for me.

  4. paveljanik commented at 5:40 AM on May 28, 2015: contributor

    I also prefer Peter's comment over changing so many files.

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

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

  7. ghost commented at 4:25 PM on May 28, 2015: none

    The #6198 comment will make a nice addition this PR (#6197), which has now been updated accordingly. Sipa's AMOUNT_OVERFLOW_PROTECTION_THRESHOLD is an elegant way to resolve the controversy. I see other implementations as no reason to perpetuate it.

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

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

  10. 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_xxx is sort of appropriate, the new name is a bit awkward and pedantic (but correct). Getting rid of the word money on the other hand is nice...

  11. 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"

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

  13. 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_XYZ is 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.

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

  15. maaku commented at 6:28 PM on May 30, 2015: contributor

    Tested ACK.

  16. paveljanik commented at 11:21 AM on May 31, 2015: contributor

    @21E14 BTW, MoneyRange() is OK for you?

  17. maaku commented at 9:37 AM on June 1, 2015: contributor

    Needs rebase

  18. ghost commented at 2:29 AM on June 2, 2015: none

    Rebased.

  19. Rename MAX_MONEY to AMOUNT_OVERFLOW_PROTECTION_THRESHOLD for improved semantics c547b48c01
  20. 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.

  21. laanwj closed this on Jun 12, 2015

  22. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me