Source code organization
Issue #15732 describes how the Bitcoin Core project is striving to organize libraries and their associated source code, copied below for convenience:
Here is how I am thinking about the organization:
libbitcoin_server.a
,libbitcoin_wallet.a
, andlibbitcoinqt.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
andlibbitcoin_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-levelsrc/common/
directory complementingsrc/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 bylibbitcoin_server.a
,libbitcoin_wallet.a
, andlibbitcoinqt.a
, and they can depend onlibbitcoin_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 insrc/util
, alllibbitcoin_consensus.a
source files lived insrc/consensus
, and alllibbitcoin_server.a
code lived insrc/node
(and maybe the library was calledlibbitcoin_node.a
).
You can track the progress of these changes by following links from the issue to associated PRs.
The libbitcoin-kernel
project will provide further clean-ups and improvements in this area.
If you want to explore for yourself which sources certain libraries require on the current codebase, you can open the file src/Makefile.am
and search for _SOURCES
.