Skip to content

Conversation

jonasschnelli
Copy link
Contributor

Another try...

Move all wallet RPC commands definitions and dispatch entries to wallet/wallet_rpcdispatch.h.
Allow extending the RPC dispatch table by appending commands when server is not running.

Motivation:

  • wallet/core code seperation
  • better interface for integrating another wallet

@laanwj
Copy link
Member

laanwj commented Jan 7, 2016

Concept ACK. It's good that 'modules' can register their own RPC calls. The wallet is a prime example of this, but there may be more in the future.

Some nits:

  • walletRegisterRPCCommands should not be on CWallet. CWallet is the class that implements the wallet not its RPC interface. A better place is in rpcwallet.cpp.
  • walletRegisterRPCCommands implementation should not be in the header file, but in an implementation file
  • The contents (initialization) of const CRPCCommand vWalletRPCCommands[] belong in an implementation file, not a header file. Having a data structure initialization in a header file means it can only be included in one place, otherwise there will be duplicate definition errors.

@jonasschnelli
Copy link
Contributor Author

Agreed with and fixed @laanwj points/nits.

Having a data structure initialization in a header file means it can only be included in one place, otherwise there will be duplicate definition errors.

Just curios: wouldn't this be avoided because of the headers preprocessor marcos (like #ifndef BITCOIN_WALLET_RPCWALLET_H)

@paveljanik
Copy link
Contributor

@jonasschnelli No. Think about including this file into two separately compiled source files. Compile works. Link phase fails.

void walletRegisterRPCCommands()
{
unsigned int vcidx;
for (vcidx = 0; vcidx < (sizeof(vWalletRPCCommands) / sizeof(vWalletRPCCommands[0])); vcidx++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ARRAYLEN() macro.

@jgarzik
Copy link
Contributor

jgarzik commented Jan 7, 2016

ut ACK

Note - The need to define functions in rpcwallet.h is greatly diminished. The rpcwallet.cpp externs could be removed from rpcwallet.h right now. The only reference is the in-rpcwallet call table.

@jonasschnelli
Copy link
Contributor Author

@jgarzik: Your totally right. Removed the function definitions in rpcwallet.h, kept some (functions of rpcdump.cpp) in rpcwallet.cpp.

@jonasschnelli
Copy link
Contributor Author

Rebased.
Would be nice to get some ACKs or NACKs because this PR tend to get merge conflicts very quick.

@maflcko
Copy link
Member

maflcko commented Jan 15, 2016

Concept ACK

Allow extending the rpc dispatch table by appending commands when server is not running.
@laanwj laanwj merged commit dd2dc40 into master Jan 20, 2016
laanwj added a commit that referenced this pull request Jan 20, 2016
…llet/ code

dd2dc40 [RPC, Wallet] Move RPC dispatch table registration to wallet/ code (Jonas Schnelli)
@laanwj
Copy link
Member

laanwj commented Jan 20, 2016

utACK

@jonasschnelli jonasschnelli deleted the 2016/01/corewallet branch January 21, 2016 08:02
laanwj added a commit to laanwj/bitcoin that referenced this pull request Mar 31, 2016
Split out methods to every module, apart from 'help' and 'stop' which
are implemented in rpcserver.cpp itself.

- This makes it easier to add or remove RPC commands - no longer everything that includes
    rpcserver.h has to be rebuilt when there's a change there.
- Cleans up `rpc/server.h` by getting rid of the huge cluttered list of function definitions.
- Removes most of the bitcoin-specific code from rpcserver.cpp and .h.

Continues bitcoin#7307 for the non-wallet.
deadalnix pushed a commit to deadalnix/bitcoin that referenced this pull request Jan 19, 2017
Split out methods to every module, apart from 'help' and 'stop' which
are implemented in rpcserver.cpp itself.

- This makes it easier to add or remove RPC commands - no longer everything that includes
    rpcserver.h has to be rebuilt when there's a change there.
- Cleans up `rpc/server.h` by getting rid of the huge cluttered list of function definitions.
- Removes most of the bitcoin-specific code from rpcserver.cpp and .h.

Continues bitcoin#7307 for the non-wallet.
deadalnix pushed a commit to deadalnix/bitcoin that referenced this pull request Feb 12, 2017
Split out methods to every module, apart from 'help' and 'stop' which
are implemented in rpcserver.cpp itself.

- This makes it easier to add or remove RPC commands - no longer everything that includes
    rpcserver.h has to be rebuilt when there's a change there.
- Cleans up `rpc/server.h` by getting rid of the huge cluttered list of function definitions.
- Removes most of the bitcoin-specific code from rpcserver.cpp and .h.

Continues bitcoin#7307 for the non-wallet.
sickpig referenced this pull request in sickpig/BitcoinUnlimited Feb 20, 2017
Split out methods to every module, apart from 'help' and 'stop' which
are implemented in rpcserver.cpp itself.

- This makes it easier to add or remove RPC commands - no longer everything that includes
    rpcserver.h has to be rebuilt when there's a change there.
- Cleans up `rpc/server.h` by getting rid of the huge cluttered list of function definitions.
- Removes most of the bitcoin-specific code from rpcserver.cpp and .h.

Continues #7307 for the non-wallet.
codablock pushed a commit to codablock/dash that referenced this pull request Dec 9, 2017
…n to wallet/ code

dd2dc40 [RPC, Wallet] Move RPC dispatch table registration to wallet/ code (Jonas Schnelli)
codablock added a commit to codablock/dash that referenced this pull request Dec 9, 2017
…was backported

Allows to compile with no wallet again.
codablock added a commit to codablock/dash that referenced this pull request Dec 11, 2017
…was backported

Allows to compile with no wallet again.
zkbot added a commit to zcash/zcash that referenced this pull request Jun 20, 2018
RPC code refactor

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7307
- bitcoin/bitcoin#7348
- bitcoin/bitcoin#7766
zkbot added a commit to zcash/zcash that referenced this pull request Jul 18, 2018
RPC code refactor

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7307
- bitcoin/bitcoin#7348
- bitcoin/bitcoin#7766
zkbot added a commit to zcash/zcash that referenced this pull request Jul 18, 2018
RPC code refactor

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7307
- bitcoin/bitcoin#7348
- bitcoin/bitcoin#7766
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request Jul 1, 2020
9f4868a [move] move listunspent to wallet/rpcwallet.cpp (furszy)
e85e4f1 [RPC] Move RPC dispatch table registration to rpcwallet code (furszy)
c0bc348 [RPC] push down reqWallet [first step] (furszy)
cdb80a6 [RPC] Remove not used threadsafe in CRPCCommand (furszy)

Pull request description:

  Initial work over the RPC dispatch table registration update.

  Includes the following changes:

  1) Remove the unused threadSafe member from every CPRCCommand. (bitcoin#5711 , second commit)
  2) Remove reqWallet from every CPRCCommand (bitcoin#5992 , second commit partially).
  3) Move most of the wallet RPC commands registration to the rpcwallet file (bitcoin#7307 without the `EnsureWalletIsAvailable` on every RPC call --> mainly because the wallet RPC commands will only be registered if the wallet is available).

  to do: Move the remaining commands that were not moved from server to rpcwallet.

  ----------

  Next step would be bitcoin#7766 (If anyone want to tackle it, feel more than welcome to tackle it).

ACKs for top commit:
  Fuzzbawls:
    ACK 9f4868a
  random-zebra:
    All good. ACK 9f4868a and merging...

Tree-SHA512: cd83cdc2de81efb5cb84d39753a160b19d8ca2967a1b303d85c3279559b478352c5a4316942c7a654e9c667b5a8f5bfa18020c1b6c9e78f4c408028840d0fc86
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants