Library source code organization #15732

issue MarcoFalke opened this issue on April 3, 2019
  1. MarcoFalke commented at 7:05 PM on April 3, 2019: member

    (copied from #15638 (comment) by @ryanofsky) Here is how I am thinking about the organization:

    • libbitcoin_server.a, libbitcoin_wallet.a, and libbitcoinqt.a should all be terminal dependencies. They should be able to depend on other symbols in other libraries, but no other libraries should depend on symbols in them (and they shouldn't depend on each other).

    • libbitcoin_consensus.a should be a standalone library that doesn't depend on symbols in other libraries mentioned here

    • libbitcoin_common.a and libbitcoin_util.a seem very interchangeable right now and mutually depend on each other. I think we should either merge them into one library, or create a new top-level src/common/ directory complementing src/util/, and start to distinguish general purpose utility code (like argument parsing) from bitcoin-specific utility code (like formatting bip32 paths and using ChainParams). Both these libraries can be depended on by libbitcoin_server.a, libbitcoin_wallet.a, and libbitcoinqt.a, and they can depend on libbitcoin_consensus.a. If we want to split util and common up, as opposed to merging them together, then util shouldn't depend on libconsensus, but common should.

    Over time, I think it'd be nice if source code organization reflected library organization . I think it'd be nice if all libbitcoin_util source files lived in src/util, all libbitcoin_consensus.a source files lived in src/consensus, and all libbitcoin_server.a code lived in src/node (and maybe the library was called libbitcoin_node.a).

  2. MarcoFalke added the label Brainstorming on Apr 3, 2019
  3. MarcoFalke added the label Build system on Apr 3, 2019
  4. MarcoFalke commented at 7:06 PM on April 3, 2019: member

    See also:

    • Source code organization for standalone (util) functions and types #14721
  5. jnewbery cross-referenced this on Apr 10, 2019 from issue Move-only: Pull wallet code out of libbitcoin_server by ryanofsky
  6. laanwj commented at 1:20 PM on April 10, 2019: member

    libbitcoin_common.a and libbitcoin_util.a seem very interchangeable right now and mutually depend on each other

    interesting—util is linked by:

    bitcoind
    bitcoin-cli
    bitcoin-tx
    bitcoin-wallet
    bench/bench_bitcoin
    qt/bitcoin-qt
    qt/test/test_bitcoin-qt
    test/test_bitcoin
    

    whereas common is linked by:

    bitcoind
    bitcoin-tx
    bitcoin-wallet
    bench/bench_bitcoin
    qt/bitcoin-qt
    qt/test/test_bitcoin-qt
    test/test_bitcoin
    

    The only difference being bitcoin-cli. Yes, with this I'd say it makes sense to merge them, unless the current split avoids pulling in some dependencies for bitcoin-cli (@luke-jr might be able to comment w.r.t. gentoo). This can't be true if there are bidirectional dependencies between them.

  7. scravy cross-referenced this on Apr 10, 2019 from issue Organization of Source Code by scravy
  8. sipa commented at 2:36 PM on April 10, 2019: member

    Concept ACK on the organization plan above.

    I feel that there is place for a distinction between common and util, through the question "bitcoin specific logic". For example, transaction signing seems to belong in a very different place than command-line handling logic, and bitcoin-cli shouldn't need to include the former.

    However it seems that in practice this distinction isn't really followed, so it may be better to just merge common and util to remove the mutual dependency, and the later carve out the real "util" parts.

  9. ryanofsky cross-referenced this on Aug 26, 2019 from issue move-only: move coins statistics utils out of RPC by jamesob
  10. MarcoFalke cross-referenced this on Sep 6, 2019 from issue doc: Consider adding README.md to build-aux/, share/, src/ by ch4ot1c
  11. ryanofsky cross-referenced this on Oct 10, 2019 from issue Replace Connman and BanMan globals with NodeContext local by ryanofsky
  12. MarcoFalke cross-referenced this on Jan 23, 2020 from issue refactor: Abstract boost::variant out by elichai
  13. ryanofsky cross-referenced this on Apr 3, 2020 from issue bitcoin-tx (and probably others) fails to build without libevent by luke-jr
  14. fanquake cross-referenced this on Sep 11, 2021 from issue consensus: move amount.h into consensus by fanquake
  15. hebasto commented at 3:11 PM on September 25, 2021: member

    it'd be nice if source code organization reflected library organization

    Concept ACK.

  16. MarcoFalke cross-referenced this on Sep 29, 2021 from issue Move-only: bloom to src/common by MarcoFalke
  17. practicalswift commented at 8:25 AM on September 30, 2021: contributor

    Concept ACK

  18. MarcoFalke referenced this in commit 816e15ee81 on Oct 5, 2021
  19. fanquake referenced this in commit c53e95f22c on Oct 21, 2021
  20. MarcoFalke cross-referenced this on Nov 4, 2021 from issue Source code organization for standalone (util) functions and types by MarcoFalke
  21. MarcoFalke referenced this in commit ca6163550c on Nov 6, 2021
  22. ryanofsky cross-referenced this on Nov 12, 2021 from issue Add `src/node/` and `src/wallet/` code to `node::` and `wallet::` namespaces by ryanofsky
  23. MarcoFalke referenced this in commit c561f2f06e on Jan 11, 2022
  24. MarcoFalke commented at 7:49 PM on February 10, 2022: member

    See also #24303

  25. MarcoFalke closed this on May 12, 2022

  26. fanquake cross-referenced this on Jun 1, 2022 from issue consensus: move version.h into consensus/ by fanquake
  27. bitcoin locked this on May 12, 2023

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-05-20 06:54 UTC