Skip to content

Commit 6a1343f

Browse files
committed
Merge #8977: [Wallet] Refactor wallet/init interaction (Reaccept wtx, flush thread)
cab1da7 [Wallet] Refactor wallet/init interaction (Reaccept wtx, flush thread) (Jonas Schnelli)
2 parents c05db83 + cab1da7 commit 6a1343f

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
@@ -1496,13 +1496,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
14961496
uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait);
14971497
}
14981498

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

15081501
//// debug print
@@ -1540,10 +1533,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
15401533
uiInterface.InitMessage(_("Done loading"));
15411534

15421535
#ifdef ENABLE_WALLET
1543-
if (pwalletMain) {
1544-
// Run a thread to flush wallet periodically
1545-
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
1546-
}
1536+
if (pwalletMain)
1537+
pwalletMain->postInitProcess(threadGroup);
15471538
#endif
15481539

15491540
return !fRequestShutdown;

src/wallet/wallet.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,6 +3549,16 @@ bool CWallet::InitLoadWallet()
35493549
return true;
35503550
}
35513551

3552+
void CWallet::postInitProcess(boost::thread_group& threadGroup)
3553+
{
3554+
// Add wallet transactions that aren't already in a block to mempool
3555+
// Do this here as mempool requires genesis block to be loaded
3556+
ReacceptWalletTransactions();
3557+
3558+
// Run a thread to flush wallet periodically
3559+
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(this->strWalletFile)));
3560+
}
3561+
35523562
bool CWallet::ParameterInteraction()
35533563
{
35543564
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)