2

There is a directory called interfaces. I've seen usage of interface classes in other places but never understood how do they work because they're trivially just an interface and therefore do nothing by their own. Can someone explain the mechanism they work in the code?

2 Answers 2

5

The interfaces classes just provide API definitions.

For example the interface::Wallet class declares a virtual interfaces::Wallet::getWalletTxs() method that GUI code can call to list wallet transactions. Wallet code provides a wallet::WalletImpl class that inherits from interfaces::Wallet and provides a wallet::WalletImpl::getWalletTxs() implementation of that method.

Because of the interface definition, GUI code can call the wallet code through the interface without being linked to wallet code or even necessarily running in the same process.

0

I think these interfaces are exclusively used in the running of Bitcoin Core in multiprocess mode (1, 2). When running Bitcoin Core as a single process (which is the default mode) these interfaces aren't used. However, multi processes need a way for a process to communicate with another process and this is done through these well defined interfaces.

2
  • 1
    That's not correct. They're used right now already for interaction between various components (though the goal of this is having a unified interface between components, so that later those components may end up running in different processes). Nov 15 at 19:53
  • Ok I'll wait for your answer on this then. Feel free to downvote this :) Nov 15 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.