From 3ea8b75281edc60078423bd5d277cd2a84aa5d33 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 30 Sep 2017 23:49:59 -0400 Subject: [PATCH] Give ZMQ consistent order with UpdatedBlockTip on scheduler thread Note that UpdatedBlockTip is also used in net_processing to announce new blocks to peers. As this may need additional review, this change is included in its own commit. --- src/validationinterface.cpp | 4 +++- src/validationinterface.h | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index c6a021119e1de..d91707cf9fe09 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -117,7 +117,9 @@ void CMainSignals::MempoolEntryRemoved(CTransactionRef ptx, MemPoolRemovalReason } void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) { - m_internals->UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload); + m_internals->m_schedulerClient.AddToProcessQueue([pindexNew, pindexFork, fInitialDownload, this] { + m_internals->UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload); + }); } void CMainSignals::TransactionAddedToMempool(const CTransactionRef &ptx) { diff --git a/src/validationinterface.h b/src/validationinterface.h index 9b5ac2ac233a1..1494c6dc21edc 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -45,7 +45,11 @@ void CallFunctionInValidationInterfaceQueue(std::function func); class CValidationInterface { protected: - /** Notifies listeners of updated block chain tip */ + /** + * Notifies listeners of updated block chain tip + * + * Called on a background thread. + */ virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {} /** * Notifies listeners of a transaction having been added to mempool.