Skip to content

Commit cab1da7

Browse files
committed
[Wallet] Refactor wallet/init interaction (Reaccept wtx, flush thread)
1 parent c587577 commit cab1da7

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/init.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,13 +1493,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
14931493
uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait);
14941494
}
14951495

1496-
#ifdef ENABLE_WALLET
1497-
// Add wallet transactions that aren't already in a block to mempool
1498-
// Do this here as mempool requires genesis block to be loaded
1499-
if (pwalletMain)
1500-
pwalletMain->ReacceptWalletTransactions();
1501-
#endif
1502-
15031496
// ********************************************************* Step 11: start node
15041497

15051498
//// debug print
@@ -1537,10 +1530,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
15371530
uiInterface.InitMessage(_("Done loading"));
15381531

15391532
#ifdef ENABLE_WALLET
1540-
if (pwalletMain) {
1541-
// Run a thread to flush wallet periodically
1542-
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
1543-
}
1533+
if (pwalletMain)
1534+
pwalletMain->postInitProcess(threadGroup);
15441535
#endif
15451536

15461537
return !fRequestShutdown;

src/wallet/wallet.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,6 +3472,16 @@ bool CWallet::InitLoadWallet()
34723472
return true;
34733473
}
34743474

3475+
void CWallet::postInitProcess(boost::thread_group& threadGroup)
3476+
{
3477+
// Add wallet transactions that aren't already in a block to mempool
3478+
// Do this here as mempool requires genesis block to be loaded
3479+
ReacceptWalletTransactions();
3480+
3481+
// Run a thread to flush wallet periodically
3482+
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(this->strWalletFile)));
3483+
}
3484+
34753485
bool CWallet::ParameterInteraction()
34763486
{
34773487
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))

src/wallet/wallet.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <vector>
2828

2929
#include <boost/shared_ptr.hpp>
30+
#include <boost/thread.hpp>
3031

3132
extern CWallet* pwalletMain;
3233

@@ -912,6 +913,12 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
912913
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
913914
static bool InitLoadWallet();
914915

916+
/**
917+
* Wallet post-init setup
918+
* Gives the wallet a chance to register repetitive tasks and complete post-init tasks
919+
*/
920+
void postInitProcess(boost::thread_group& threadGroup);
921+
915922
/* Wallets parameter interaction */
916923
static bool ParameterInteraction();
917924

0 commit comments

Comments
 (0)