8.2 KiB
Libraries
Name | Description |
---|---|
libmoneyrocket_cli | RPC client functionality used by moneyrocket-cli executable |
libmoneyrocket_common | Home for common functionality shared by different executables and libraries. Similar to libmoneyrocket_util, but higher-level (see Dependencies). |
libmoneyrocket_consensus | Stable, backwards-compatible consensus functionality used by libmoneyrocket_node and libmoneyrocket_wallet and also exposed as a shared library. |
libmoneyrocketconsensus | Shared library build of static libmoneyrocket_consensus library |
libmoneyrocket_kernel | Consensus engine and support library used for validation by libmoneyrocket_node and also exposed as a shared library. |
libmoneyrocketqt | GUI functionality used by moneyrocket-qt and moneyrocket-gui executables |
libmoneyrocket_ipc | IPC functionality used by moneyrocket-node, moneyrocket-wallet, moneyrocket-gui executables to communicate when --enable-multiprocess is used. |
libmoneyrocket_node | P2P and RPC server functionality used by moneyrocketd and moneyrocket-qt executables. |
libmoneyrocket_util | Home for common functionality shared by different executables and libraries. Similar to libmoneyrocket_common, but lower-level (see Dependencies). |
libmoneyrocket_wallet | Wallet functionality used by moneyrocketd and moneyrocket-wallet executables. |
libmoneyrocket_wallet_tool | Lower-level wallet functionality used by moneyrocket-wallet executable. |
libmoneyrocket_zmq | ZeroMQ functionality used by moneyrocketd and moneyrocket-qt executables. |
Conventions
-
Most libraries are internal libraries and have APIs which are completely unstable! There are few or no restrictions on backwards compatibility or rules about external dependencies. Exceptions are libmoneyrocket_consensus and libmoneyrocket_kernel which have external interfaces documented at ../shared-libraries.md.
-
Generally each library should have a corresponding source directory and namespace. Source code organization is a work in progress, so it is true that some namespaces are applied inconsistently, and if you look at
libmoneyrocket_*_SOURCES
lists you can see that many libraries pull in files from outside their source directory. But when working with libraries, it is good to follow a consistent pattern like:- libmoneyrocket_node code lives in
src/node/
in thenode::
namespace - libmoneyrocket_wallet code lives in
src/wallet/
in thewallet::
namespace - libmoneyrocket_ipc code lives in
src/ipc/
in theipc::
namespace - libmoneyrocket_util code lives in
src/util/
in theutil::
namespace - libmoneyrocket_consensus code lives in
src/consensus/
in theConsensus::
namespace
- libmoneyrocket_node code lives in
Dependencies
- Libraries should minimize what other libraries they depend on, and only reference symbols following the arrows shown in the dependency graph below:
|
Dependency graph. Arrows show linker symbol dependencies. Consensus lib depends on nothing. Util lib is depended on by everything. Kernel lib depends only on consensus and util. |
-
The graph shows what linker symbols (functions and variables) from each library other libraries can call and reference directly, but it is not a call graph. For example, there is no arrow connecting libmoneyrocket_wallet and libmoneyrocket_node libraries, because these libraries are intended to be modular and not depend on each other's internal implementation details. But wallet code is still able to call node code indirectly through the
interfaces::Chain
abstract class ininterfaces/chain.h
and node code calls wallet code through theinterfaces::ChainClient
andinterfaces::Chain::Notifications
abstract classes in the same file. In general, defining abstract classes insrc/interfaces/
can be a convenient way of avoiding unwanted direct dependencies or circular dependencies between libraries. -
libmoneyrocket_consensus should be a standalone dependency that any library can depend on, and it should not depend on any other libraries itself.
-
libmoneyrocket_util should also be a standalone dependency that any library can depend on, and it should not depend on other internal libraries.
-
libmoneyrocket_common should serve a similar function as libmoneyrocket_util and be a place for miscellaneous code used by various daemon, GUI, and CLI applications and libraries to live. It should not depend on anything other than libmoneyrocket_util and libmoneyrocket_consensus. The boundary between util and common is a little fuzzy but historically util has been used for more generic, lower-level things like parsing hex, and common has been used for moneyrocket-specific, higher-level things like parsing base58. The difference between util and common is mostly important because libmoneyrocket_kernel is not supposed to depend on libmoneyrocket_common, only libmoneyrocket_util. In general, if it is ever unclear whether it is better to add code to util or common, it is probably better to add it to common unless it is very generically useful or useful particularly to include in the kernel.
-
libmoneyrocket_kernel should only depend on libmoneyrocket_util and libmoneyrocket_consensus.
-
The only thing that should depend on libmoneyrocket_kernel internally should be libmoneyrocket_node. GUI and wallet libraries libmoneyrocketqt and libmoneyrocket_wallet in particular should not depend on libmoneyrocket_kernel and the unneeded functionality it would pull in, like block validation. To the extent that GUI and wallet code need scripting and signing functionality, they should be get able it from libmoneyrocket_consensus, libmoneyrocket_common, and libmoneyrocket_util, instead of libmoneyrocket_kernel.
-
GUI, node, and wallet code internal implementations should all be independent of each other, and the libmoneyrocketqt, libmoneyrocket_node, libmoneyrocket_wallet libraries should never reference each other's symbols. They should only call each other through
src/interfaces/
abstract interfaces.
Work in progress
- Validation code is moving from libmoneyrocket_node to libmoneyrocket_kernel as part of The libmoneyrocketkernel Project #24303
- Source code organization is discussed in general in Library source code organization #15732