wallet: don't include bdb files from our headers #28039

pull theuni wants to merge 7 commits into bitcoin:master from theuni:bdb-no-include-from-headers changing 3 files +60 −43
  1. theuni commented at 8:05 PM on July 6, 2023: member

    Only #include upstream bdb headers from our cpp files.

    It's generally good practice to avoid including 3rd party deps in headers as otherwise they tend to sneak into new compilation units. IMO this makes for a nice cleanup.

    There's a good bit of code movement here, but each commit is small and should be obviously correct.

    Note: in the future, the buildsystem can add the bdb include path for bdb.cpp and salvage.cpp only, rather than all wallet sources.

  2. DrahtBot commented at 8:06 PM on July 6, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hebasto, achow101

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Wallet on Jul 6, 2023
  4. wallet: bdb: drop default parameter 43369f3706
  5. wallet: bdb: move TxnBegin to cpp file since it uses a bdb function 4216f69250
  6. theuni force-pushed on Jul 6, 2023
  7. achow101 commented at 9:21 PM on July 6, 2023: member

    ACK 2d09d0f50408f9c522b9efa4f386072502c7b3d1

    Changes are primarily moves and appear otherwise obviously correct.

  8. in src/wallet/bdb.cpp:274 in c217c542f0 outdated
     270 | @@ -275,6 +271,11 @@ SafeDbt::operator Dbt*()
     271 |      return &m_dbt;
     272 |  }
     273 |  
     274 | +Span<const std::byte> SpanFromDbt(const SafeDbt& dbt)
    


    maflcko commented at 6:03 AM on July 7, 2023:

    nit in c217c542f0fd9c741b79a91419247bd44440e6d9: I think you forgot static or namespace?


    theuni commented at 2:17 PM on July 7, 2023:

    Nice catch. Fixed.

  9. maflcko approved
  10. maflcko commented at 6:07 AM on July 7, 2023: member

    lgtm

  11. fanquake referenced this in commit 334f45fe62 on Jul 7, 2023
  12. hebasto approved
  13. hebasto commented at 9:05 AM on July 7, 2023: member

    Approach ACK 2d09d0f50408f9c522b9efa4f386072502c7b3d1.

    Suggesting to adjust our IWYU mapping file:

    --- a/contrib/devtools/iwyu/bitcoin.core.imp
    +++ b/contrib/devtools/iwyu/bitcoin.core.imp
    @@ -4,4 +4,7 @@
       { include: [ "<bits/termios-struct.h>", private, "<termios.h>", public ] },
       { include: [ "<bits/termios-tcflow.h>", private, "<termios.h>", public ] },
       { include: [ "<bits/chrono.h>", private, "<chrono>", public ] },
    +
    +  # Berkeley DB
    +  { include: [ "<db.h>", private, "<db_cxx.h>", public ] },
     ]
    

    or #include <db.h> explicitly along with #include <db_cxx.h>.

  14. wallet: bdb: move SpanFromDbt to below SafeDbt's implementation
    No functional change, just simplifies the code move in the next commit.
    e5e5aa1da2
  15. wallet: bdb: move SafeDbt to cpp file
    Dbt requires including bdb headers.
    b3582baa3a
  16. wallet: bdb: move BerkeleyDatabase constructor to cpp file
    Else some compilers/stdlibs may not be able to construct
    std::unique_ptr<Db> without Db defined.
    004b184b02
  17. wallet: bdb: don't use bdb define in header 6e010626af
  18. wallet: bdb: include bdb header from our implementation files only
    This way the dependency can't sneak into other files without being noticed.
    
    Forward-declare bdb classes as necessary.
    8b5397c00e
  19. theuni force-pushed on Jul 7, 2023
  20. hebasto approved
  21. hebasto commented at 2:19 PM on July 7, 2023: member

    ACK 8b5397c00e821d7eaab22f512e9d71a1a0392ebf

  22. DrahtBot requested review from achow101 on Jul 7, 2023
  23. theuni commented at 2:29 PM on July 7, 2023: member

    @hebasto I'm ~0 on doing either/none of those changes. Happy to make a change if you or @achow101 or @MarcoFalke have a strong preference, otherwise I'll leave it as-is.

  24. sidhujag referenced this in commit d78a36326f on Jul 7, 2023
  25. achow101 commented at 5:19 PM on July 7, 2023: member

    reACK 8b5397c00e821d7eaab22f512e9d71a1a0392ebf

    No preference to make those changes.

  26. DrahtBot removed review request from achow101 on Jul 7, 2023
  27. achow101 merged this on Jul 7, 2023
  28. achow101 closed this on Jul 7, 2023

  29. sidhujag referenced this in commit 8ef8a53240 on Jul 7, 2023
  30. bitcoin locked this on Dec 5, 2024

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-18 15:13 UTC

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