diff --git a/src/init.cpp b/src/init.cpp index 39065a88d..e2b92b5e5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1545,6 +1545,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif // ENABLE_MINING + // Start the thread that notifies listeners of transactions that have been + // recently added to the mempool, or have been added to or removed from the + // chain. + + boost::function threadnotifywallets = boost::bind(&ThreadNotifyWallets, chainActive.Tip()); + threadGroup.create_thread( + boost::bind(&TraceThread>, "txnotify", threadnotifywallets) + ); + // ********************************************************* Step 9: data directory maintenance // if pruning, unset the service bit and perform the initial blockstore prune @@ -1599,10 +1608,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0); #endif - // Start the thread that notifies listeners of transactions that have been - // recently added to the mempool, or have been added to or removed from the - // chain. - threadGroup.create_thread(boost::bind(&TraceThread, "txnotify", &ThreadNotifyWallets)); if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) StartTorControl(threadGroup, scheduler); diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 405359347..5e95679e9 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -81,13 +81,9 @@ struct CachedBlockData { pindex(pindex), oldTrees(oldTrees), txConflicted(txConflicted) {} }; -void ThreadNotifyWallets() +void ThreadNotifyWallets(CBlockIndex *pindexLastTip) { - CBlockIndex *pindexLastTip = nullptr; - { - LOCK(cs_main); - pindexLastTip = chainActive.Tip(); - } + assert(pindexLastTip != nullptr); while (true) { // Run the notifier on an integer second in the steady clock. diff --git a/src/validationinterface.h b/src/validationinterface.h index 55a7f5f44..3072e5a0a 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -74,6 +74,6 @@ struct CMainSignals { CMainSignals& GetMainSignals(); -void ThreadNotifyWallets(); +void ThreadNotifyWallets(CBlockIndex *pindexLastTip); #endif // BITCOIN_VALIDATIONINTERFACE_H