[wallet] Clarify wallet initialization / destruction interface #10767

Open
wants to merge 12 commits into
from

Conversation

Projects
None yet
4 participants
Member

jnewbery commented Jul 7, 2017

Apologies for the mostly code move only PR. This is a pre-req for both #10740 and #10762

All wallet component initialization/destruction functions are now in their own walletinit.cpp translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet.

A few small changes in behavior. The most important one is that Flush() no longer gets called twice on shutdown. I think this is fine, and all the tests pass, but this probably requires some careful consideration from people who are more familiar with the wallet code.

Lots of commits to aid reviewers. Can be squashed down prior to merge.

jnewbery added some commits Jul 3, 2017

@jnewbery jnewbery [wallet] Add walletinit.cpp
This commit adds a new walletinit translation unit and moves
GetWalletHelpString() to walletinit from a static member function of
CWallet.

Apart from adding the new translation unit, this is a MOVE-ONLY commit.
1e688b7
@jnewbery jnewbery [wallet] Move WalletParameterInteraction() to walletinit.cpp
This is a MOVE-ONLY commit.
f548c07
@jnewbery jnewbery [wallet] Move VerifyWallets() to walletinit.cpp
MOVE-ONLY commit
2c3bc24
@jnewbery jnewbery [wallet] Add RegisterWalletRPC to walletinit.cpp
Adds a RegisterWalletRPC() to walletinit.cpp. This just calls through to
RegisterWalletRPCCommands() in rpcwallet.cpp.
d557f80
@jnewbery jnewbery [wallet] Allow individual wallets to be verified
Removes the VerifyEnvironment() functions from CDB and CWalletDB.
Environment verification is now done in walletinit.
54b1a43
@jnewbery jnewbery [wallet] Add AttachWallets() to walletinit.cpp
Moves InitLoadWallets() to walletinit.cpp and renames it to
AttachWallets. Apart from the name change, this is a MOVE-ONLY commit.
6c10c46
@jnewbery jnewbery [wallet] Add WalletCompleteStartup() to walletinit.cpp
This is more or less a CODE-MOVE only.
05e5f5f
@jnewbery jnewbery [wallet] Move FlushWallets and DeleteWallets to walletinit.cpp
CODE-MOVE only

This completes the movement of wallet initialization functions to
walletinit.cpp. init.cpp now has an interface to the wallet consisting
of the following functions:

- GetWalletHelpString()
- RegisterWalletRPCCommands()
- WalletParameterInteraction()
- VerifyWallets()
- AttachWallets()
- WalletCompleteStartup()
- FlushWallets()
- DeleteWallets()
3a86d2f
@jnewbery jnewbery [wallet] Add CDBEnv::Shutdown() function
CODE-MOVE only
e8f4815
@jnewbery jnewbery [wallet] Call CDBEnv.shutdown() from FlushWallets()
This commit removes the call to CDBEnv.Shutdown() from CDBEnv.Flush()
and calls CDBEnv.Shutdown directly from ShutdownWallets() in
walletinit.cpp.

This also changes the interface to CDBEnv.Flush() to allow an individual
wallet to be flushed.
9bfdaf9
@jnewbery jnewbery [wallet] Remove early call to FlushWallets()
This commit removes the early call to FlushWallets() in the init.cpp Shutdown() function.

This appears to be vestigial Satoshi-era code.
1dc6393
@jnewbery jnewbery [wallet] Rename wallet shutdown functions
Renames FlushWallets() and DeleteWallets() to ShutdownWallets() and
DetachWallets()
3696ed0
@@ -187,11 +187,6 @@ void Shutdown()
StopREST();
StopRPC();
StopHTTPServer();
-#ifdef ENABLE_WALLET
@promag

promag Jul 7, 2017

Contributor

Nothing replacing this code?

@jnewbery

jnewbery Jul 7, 2017

Member

Correct - I don't believe the early wallet flush is necessary (although I may be wrong). See PR description:

The most important one is that Flush() no longer gets called twice on shutdown. I think this is fine, and all the tests pass, but this probably requires some careful consideration from people who are more familiar with the wallet code.

@@ -230,9 +225,7 @@ void Shutdown()
pblocktree = NULL;
}
#ifdef ENABLE_WALLET
@promag

promag Jul 7, 2017

Contributor

What about moving these #ifdef ENABLE_WALLET to walletinit.cpp?

@jnewbery

jnewbery Jul 7, 2017

Member

Because walletinit.cpp is in libbitcoin_wallet, so is not linked if ENABLE_WALLET isn't defined. #10762 will remove the libbitcoin_server -> libbitcoin_wallet dependencies entirely from init.cpp.

jnewbery changed the title from Clarify wallet initialization / destruction interface to [wallet] Clarify wallet initialization / destruction interface Jul 11, 2017

Contributor

practicalswift commented Jul 17, 2017

Rebase needed :-)

Member

jnewbery commented Jul 17, 2017

This isn't going in until after 0.15. which includes some wallet changes. I'll rebase after 0.15 has been cut.

Contributor

practicalswift commented Jul 17, 2017

@jnewbery Got it! Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment