Initialize ThreadNotifyWallets before additional blocks are imported.

Co-authored-by: Daira Hopwood <daira@electriccoin.co>
This commit is contained in:
Sean Bowe 2020-02-26 11:19:33 -07:00
parent 77c2e1c251
commit faca79eb2f
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
3 changed files with 12 additions and 11 deletions

View File

@ -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<void()> threadnotifywallets = boost::bind(&ThreadNotifyWallets, chainActive.Tip());
threadGroup.create_thread(
boost::bind(&TraceThread<boost::function<void()>>, "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<void (*)()>, "txnotify", &ThreadNotifyWallets));
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
StartTorControl(threadGroup, scheduler);

View File

@ -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.

View File

@ -74,6 +74,6 @@ struct CMainSignals {
CMainSignals& GetMainSignals();
void ThreadNotifyWallets();
void ThreadNotifyWallets(CBlockIndex *pindexLastTip);
#endif // BITCOIN_VALIDATIONINTERFACE_H