Bad encapsulation in Bitcoin Client #1534

issue mhredmond21 opened this issue on June 29, 2012
  1. mhredmond21 commented at 3:59 PM on June 29, 2012: none

    Most of the things that reach all the way into CTransaction::CTXOut::nValue should not be doing this. The methods that do this should not technically be directly interacting even with CTXOut, except for the ones that are in CTransaction.

    Making nValue private will prevent more "bad" code from entering the client, and is the start of fixing this problem for good.

    I have made a pull request but I think it was prematurely closed.

    #1533

  2. gavinandresen commented at 4:13 PM on June 29, 2012: contributor

    Reviewing/testing changes is our bottleneck.

    There are two problems with "I'll just encapsulate this..." changes:

    1. Core developers don't have time to review an avalanche of little changes.
    2. You break other patches.

    The last release was a "code cleanup" release, that would have been a good time to do this. Getting consensus on the names of accessor routines BEFORE submitting a pull would have been a good idea, too ("GetPresentValue"... bleuch).

  3. mhredmond21 commented at 4:20 PM on June 29, 2012: none

    Not wasting your time is why I only changed one thing in the commit to close off the problem before it gets any larger than it already is. I made it easy to review intentionally.

    Present Value is the standard accepted term for the idea described by the variable "nValue."

    http://en.wikipedia.org/wiki/Present_value

    It's a very fundamental and basic term from finance and I had no idea this would be controversial.

    I assumed you would appreciate me honestly expressing my current motivation rather than obscuring it and submitting patches without any explanation as to what I'm experimenting with.

  4. gavinandresen commented at 6:18 PM on June 29, 2012: contributor

    Accessor methods are generally named "GetFoo/SetFoo", although it's not universally agreed that accessor methods and making every variable private is always the right thing to do. For a lightweight class like CTxOut, I don't see a lot of benefit to Get/Set methods.

    RE: "expressing motivation" : I haven't said anything about the motivation for this change, I'm just explaining why little changes like this aren't welcomed with open arms.

    RE: wasting time: arguing about little changes like this, exactly like we're doing now, is a big waste of time.

    PS: you might look into building on top of Michael Gronager's libcoin, it is an extensively refactored version of the Satoshi codebase: https://github.com/ceptacle/libcoin e.g. https://github.com/ceptacle/libcoin/blob/master/include/coin/Transaction.h#L197

    I can't vouch for it's security or stability, though.

  5. mhredmond21 closed this on Jun 29, 2012

  6. suprnurd referenced this in commit e0d6c5b5a2 on Dec 5, 2017
  7. DrahtBot 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-17 06:16 UTC

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