mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
a0c8c9f0a5
## Issue being fixed or feature implemented fix: possible assert call if nHeight in CDeterministicMNListDiff is higher than Tip Example of new log: ``` 2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159 ``` instead assert call: ``` ... #6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730, function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101 #7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730 #8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647) at evo/deterministicmns.cpp:231 #9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216 #10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194 #11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157 #12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) () #13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) () #14 0x0000555556844ce5 in QObject::event(QEvent*) () #15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () #16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) () #17 0x000055555686de2a in QTimerInfoList::activateTimers() () #18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () #19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () #20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () #21 0x0000555556825f8a in QCoreApplication::exec() () ... ``` ## What was done? ClientModel returns now a pair: MNList and CBlockIndex; so, we always know the which one has been used even if current chain is switched. ## How Has This Been Tested? Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` - aborted with backtrace like above. With both of commit - no assert more. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone --------- Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
75 lines
5.0 KiB
C++
75 lines
5.0 KiB
C++
// Copyright (c) 2010-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <ui_interface.h>
|
|
|
|
#include <util/translation.h>
|
|
|
|
#include <boost/signals2/optional_last_value.hpp>
|
|
#include <boost/signals2/signal.hpp>
|
|
|
|
CClientUIInterface uiInterface;
|
|
|
|
struct UISignals {
|
|
boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value<bool>> ThreadSafeMessageBox;
|
|
boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value<bool>> ThreadSafeQuestion;
|
|
boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
|
|
boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
|
|
boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
|
|
boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
|
|
boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
|
|
boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
|
|
boost::signals2::signal<CClientUIInterface::NotifyChainLockSig> NotifyChainLock;
|
|
boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
|
|
boost::signals2::signal<CClientUIInterface::NotifyMasternodeListChangedSig> NotifyMasternodeListChanged;
|
|
boost::signals2::signal<CClientUIInterface::NotifyAdditionalDataSyncProgressChangedSig> NotifyAdditionalDataSyncProgressChanged;
|
|
boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
|
|
};
|
|
static UISignals g_ui_signals;
|
|
|
|
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
|
|
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
|
|
{ \
|
|
return g_ui_signals.signal_name.connect(fn); \
|
|
}
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
|
|
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion);
|
|
ADD_SIGNALS_IMPL_WRAPPER(InitMessage);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
|
|
ADD_SIGNALS_IMPL_WRAPPER(ShowProgress);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyChainLock);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyMasternodeListChanged);
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyAdditionalDataSyncProgressChanged);
|
|
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
|
|
|
|
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
|
|
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);}
|
|
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
|
|
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
|
|
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
|
|
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
|
|
void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
|
|
void CClientUIInterface::NotifyBlockTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(b, i); }
|
|
void CClientUIInterface::NotifyChainLock(const std::string& bestChainLockHash, int bestChainLockHeight) { return g_ui_signals.NotifyChainLock(bestChainLockHash, bestChainLockHeight); }
|
|
void CClientUIInterface::NotifyHeaderTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(b, i); }
|
|
void CClientUIInterface::NotifyMasternodeListChanged(const CDeterministicMNList& list, const CBlockIndex* i) { return g_ui_signals.NotifyMasternodeListChanged(list, i); }
|
|
void CClientUIInterface::NotifyAdditionalDataSyncProgressChanged(double nSyncProgress) { return g_ui_signals.NotifyAdditionalDataSyncProgressChanged(nSyncProgress); }
|
|
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
|
|
|
|
bool InitError(const bilingual_str& str)
|
|
{
|
|
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
|
|
return false;
|
|
}
|
|
|
|
void InitWarning(const bilingual_str& str)
|
|
{
|
|
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
|
|
}
|