[qt] Add abstraction layer for accessing node and wallet functionality from gui #10244
Open
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5e49ef7
Add src/ipc/README.md
ryanofsky d815538
Remove direct bitcoin calls from qt/bitcoin.cpp
ryanofsky f15c666
Remove direct bitcoin calls from qt/optionsmodel.cpp
ryanofsky de1c51a
Remove direct bitcoin calls from qt/bitcoingui.cpp
ryanofsky bf5402d
Remove direct bitcoin calls from qt/utilitydialog.cpp
ryanofsky dfa9f2c
Remove direct bitcoin calls from qt/splashscreen.cpp
ryanofsky 027e602
Remove direct bitcoin calls from qt/clientmodel.cpp
ryanofsky 8d848cb
Remove direct bitcoin calls from qt/intro.cpp
ryanofsky 54e9432
Remove direct bitcoin calls from qt/peertablemodel.cpp
ryanofsky c08ce5b
Remove direct bitcoin calls from qt/bantablemodel.cpp
ryanofsky fec4a06
Remove direct bitcoin calls from qt/rpcconsole.cpp
ryanofsky 6a5652d
Remove direct bitcoin calls from qt/optionsdialog.cpp
ryanofsky 8ef6f04
Remove most direct bitcoin calls from qt/walletmodel.cpp
ryanofsky b588768
Remove direct bitcoin calls from qt/coincontroldialog.cpp
ryanofsky c6461dc
Remove direct bitcoin calls from qt/addresstablemodel.cpp
ryanofsky 250293f
Remove direct bitcoin calls from qt/paymentserver.cpp
ryanofsky ae06c3a
Remove direct bitcoin calls from qt transaction table files
ryanofsky c1fbdd5
Remove direct bitcoin access from qt/guiutil.cpp
ryanofsky 7b91ed1
Remove direct bitcoin calls from qt/sendcoinsdialog.cpp
ryanofsky ff16148
Merge branch 'pr/ipc-bump' into pr/ipc-local
ryanofsky b937494
Make feebumper class stateless
ryanofsky
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,64 @@ | ||
| +src/ipc -- Bitcoin Interprocess Communication | ||
| +============================================= | ||
| + | ||
| +The IPC functions and classes in [`src/ipc`](.) define interfaces that allow | ||
| +bitcoin code running in separate processes to communicate. | ||
| + | ||
| +The interfaces are designed to be protocol agnostic, so support for different | ||
| +IPC mechanisms (Capn'Proto, gRPC, JSON-RPC, or custom protocols) could be added | ||
| +without having to change application code outside the [`src/ipc`](.) directory. | ||
| + | ||
| +The interfaces are also expected to evolve over time, to allow gradually | ||
| +increasing bitcoin code modularity, starting with a simple division between | ||
| +bitcoin GUI (`bitcoin-qt`) and bitcoind daemon (`bitcoind`) code, and | ||
| +supporting more subdivisions in the future, such as subdivisions between | ||
| +bitcoin wallet code and bitcoin P2P networking code, or between P2P networking | ||
| +and database storage code. | ||
| + | ||
| +Current Status | ||
| +-------------- | ||
| + | ||
| +* [`src/ipc/interfaces.h`](interfaces.h) currently contains interfaces | ||
| + `ipc::Node` and `ipc::Wallet` allowing the bitcoin GUI to access bitcoin | ||
| + node and wallet functionality. More interfaces could be added in the future. | ||
| +* [`src/ipc/interfaces.h`](interfaces.h) currently only defines a `LOCAL` IPC protocol | ||
| + for calling functionality already linked into the current process. The first | ||
| + implementation of a remote protocol allowing real interprocess communication | ||
| + is added in PR [#10102](https://github.com/bitcoin/bitcoin/pull/10102). | ||
| + | ||
| +FAQ | ||
| +--- | ||
| + | ||
| +### Does having an IPC layer make Qt model classes redundant? | ||
| + | ||
| +The IPC layer is complementary to the Qt model classes. The IPC layer is only a | ||
| +simple shim wrapping a selection of node and wallet functions that the GUI | ||
| +needs access to. No real functionality is implemented there, and the most | ||
| +complicated thing any IPC method in | ||
| +[src/ipc/local/interfaces.cpp](local/interfaces.cpp) should do is a call a | ||
| +single bitcoin function, or batch a few function calls together and group their | ||
| +results. | ||
| + | ||
| +All real functionality is implemented outside of the IPC layer, either above it | ||
| +in Qt model classes, or below it in bitcoin node and wallet code. The Qt model | ||
| +classes in ([src/qt/walletmodel.cpp](../qt/walletmodel.cpp)), | ||
| +([src/qt/clientmodel.cpp](../qt/clientmodel.cpp), etc) are the best place to | ||
| +implement functionality that's useful to GUI code but not useful to other parts | ||
| +of bitcoin. | ||
| + | ||
| +Examples of expected code organization: | ||
| + | ||
| +* `WalletImpl::getBalances()` in | ||
| + [src/ipc/local/interfaces.cpp](local/interfaces.cpp) shows a typical IPC | ||
| + method implementation which groups together the results of a few lower-level | ||
| + bitcoin calls, but does not implement any real functionality of its own. | ||
| + | ||
| +* PR [#10231](https://github.com/bitcoin/bitcoin/pull/10231), which adds caching | ||
| + of header information to GUI, shows an example of the type of functionality | ||
| + that belongs in Qt model classes. The caching it adds could have been | ||
| + implemented at a lower level, but it belongs in Qt because the information it | ||
| + tracks is only useful to the GUI. | ||
| + | ||
| +* PR [#10251](https://github.com/bitcoin/bitcoin/pull/10251), which adds caching | ||
| + of balance information, is useful to both the GUI and the JSON-RPC interfaces, | ||
| + so was implemented at a lower level. |
| @@ -0,0 +1,15 @@ | ||
| +#include "ipc/interfaces.h" | ||
| + | ||
| +#include "ipc/local/interfaces.h" | ||
| + | ||
| +namespace ipc { | ||
| + | ||
| +std::unique_ptr<Node> MakeNode(Protocol protocol) | ||
| +{ | ||
| + if (protocol == LOCAL) { | ||
| + return local::MakeNode(); | ||
| + } | ||
| + return {}; | ||
| +} | ||
| + | ||
| +} // namespace ipc |
Oops, something went wrong.