Further reduce header dependencies #1112

pull sipa wants to merge 4 commits into bitcoin:master from sipa:saneserial changing 52 files +1005 −1015
  1. sipa commented at 1:00 PM on April 16, 2012: member

    This pull request removes the dependency of serialize.h on PROTOCOL_VERSION, and makes this parameter required instead of implicit. This is much saner in my opinion, as it makes the places where changing a version number can have an influence obvious.

    This builds upon #1109, but since it may be more controversial, it's a separate pull request.

  2. jgarzik commented at 2:28 PM on April 16, 2012: contributor

    It is unfortunate that every usage site gets larger, with this patch.

  3. sipa commented at 3:16 PM on April 16, 2012: member

    Yes, I did it that way because it exposed all places where implicit versions where being used. In many places, this implicit value must obey some hidden rules. For example, GetHash() needs to be done using a constant version number, or everything would break, but used PROTOCOL_VERSION formerly. If we ever do a protocol change that adds fields to blocks or transactions, this has to be thought through thoroughly, and many places where PROTOCOL_VERSION is used, will need to be changed to pNode->nVersion, for example. With this change, those places become obvious.

  4. sipa commented at 3:20 PM on April 16, 2012: member

    Or put otherwise: i think using PROTOCOL_VERSION is a bad default anyway, because as soon as the version number becomes relevant, every piece of code that uses the default constructor will have to be changed anyway.

  5. laanwj commented at 4:01 PM on April 16, 2012: member

    Larger, but also more explicit and less magic. I like it.

    New diagram: https://dev.visucore.com/bitcoin/includes_saneserial.svg

  6. laanwj commented at 9:23 AM on April 17, 2012: member

    I also expect that making the version parameter explicit and passing it through prevents many of the "argument unused" warnings currently emitted in the headers.

  7. sipa commented at 12:13 PM on April 17, 2012: member

    I doubt that; they don't become magically used because they're explicit instead of implicit.

  8. Remove headers.h ed6d0b5f85
  9. Move CWalletDB code to new walletdb module.
    In addition to standard code separation, this change opens the door
    to fixing several include inter-dependencies.
    9eace6b113
  10. Move proto version to version.h. Reduce header deps a bit more. ccd65d4261
  11. Further reduce header dependencies
    This commit removes the dependency of serialize.h on PROTOCOL_VERSION,
    and makes this parameter required instead of implicit. This is much saner,
    as it makes the places where changing a version number can have an
    influence obvious.
    6b6aaa1698
  12. sipa referenced this in commit 1ffeb89a52 on Apr 17, 2012
  13. sipa merged this on Apr 17, 2012
  14. sipa closed this on Apr 17, 2012

  15. coblee referenced this in commit 21ffb9dbb0 on Jul 17, 2012
  16. suprnurd referenced this in commit 768eb2044f on Dec 5, 2017
  17. lateminer referenced this in commit b10af51074 on Jan 22, 2019
  18. lateminer referenced this in commit 645854ad57 on Nov 14, 2019
  19. 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-13 21:16 UTC

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