Browse Source

[Wallet] Refactor wallet/init interaction (Reaccept wtx, flush thread)

0.14
Jonas Schnelli 8 years ago
parent
commit
cab1da745b
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 13
      src/init.cpp
  2. 10
      src/wallet/wallet.cpp
  3. 7
      src/wallet/wallet.h

13
src/init.cpp

@ -1493,13 +1493,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait);
} }
#ifdef ENABLE_WALLET
// Add wallet transactions that aren't already in a block to mempool
// Do this here as mempool requires genesis block to be loaded
if (pwalletMain)
pwalletMain->ReacceptWalletTransactions();
#endif
// ********************************************************* Step 11: start node // ********************************************************* Step 11: start node
//// debug print //// debug print
@ -1537,10 +1530,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
uiInterface.InitMessage(_("Done loading")); uiInterface.InitMessage(_("Done loading"));
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (pwalletMain) { if (pwalletMain)
// Run a thread to flush wallet periodically pwalletMain->postInitProcess(threadGroup);
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
}
#endif #endif
return !fRequestShutdown; return !fRequestShutdown;

10
src/wallet/wallet.cpp

@ -3472,6 +3472,16 @@ bool CWallet::InitLoadWallet()
return true; return true;
} }
void CWallet::postInitProcess(boost::thread_group& threadGroup)
{
// Add wallet transactions that aren't already in a block to mempool
// Do this here as mempool requires genesis block to be loaded
ReacceptWalletTransactions();
// Run a thread to flush wallet periodically
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(this->strWalletFile)));
}
bool CWallet::ParameterInteraction() bool CWallet::ParameterInteraction()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))

7
src/wallet/wallet.h

@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
extern CWallet* pwalletMain; extern CWallet* pwalletMain;
@ -912,6 +913,12 @@ public:
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */ /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
static bool InitLoadWallet(); static bool InitLoadWallet();
/**
* Wallet post-init setup
* Gives the wallet a chance to register repetitive tasks and complete post-init tasks
*/
void postInitProcess(boost::thread_group& threadGroup);
/* Wallets parameter interaction */ /* Wallets parameter interaction */
static bool ParameterInteraction(); static bool ParameterInteraction();

Loading…
Cancel
Save