Skip to content

Commit f9e123e

Browse files
Merge dashpay#5987: refactor: reduce fMasternodeMode usage, remove fDisableGovernance global
b4477e4 trivial: don't print `fDisableGovernance` value anymore (Kittywhiskers Van Gogh) a42370d refactor: remove fDisableGovernance global, define default in variable (Kittywhiskers Van Gogh) b152759 refactor: remove fMasternodeMode and fDisableGovernance from Qt code (Kittywhiskers Van Gogh) 9402ce7 refactor: limit usage of fDisableGovernance, use `IsValid()` instead (Kittywhiskers Van Gogh) 106f6bd refactor: reduce fMasternodeMode usage in governance and mnauth (Kittywhiskers Van Gogh) 3ba293f refactor: remove fMasternodeMode checks in CActiveMasternodeManager (Kittywhiskers Van Gogh) b0216ac refactor: remove fMasternodeMode usage in rpc logic (Kittywhiskers Van Gogh) 4d629a0 refactor: limit fMasternodeMode usage in blockstorage, init, net_processing (Kittywhiskers Van Gogh) a9cbdfc refactor: remove fMasternodeMode usage from llmq logic (Kittywhiskers Van Gogh) c62a3d5 refactor: remove fMasternodeMode usage from coinjoin logic (Kittywhiskers Van Gogh) Pull request description: ## Motivation Since dashpay#5940, `CActiveMasternodeManager` ceased to be a global variable and became a conditional smart pointer initialized based on the value of `fMasternodeMode`. Likewise, since dashpay#5555, we can tell if any `CFlatDB`-based manager has successfully loaded its database. `CGovernanceManager` is one of them and conditionally loads its database based on the value of `fGovernanceDisabled`. `fMasternodeMode` and `fGovernanceDisabled` were (and the former to a certain degree still is) unavoidable globals due to the way the functionality they influenced was structured (i.e. decided in initialization code with no way to query from the manager itself). As we can directly ask the managers now, we can start reducing the usage of these globals and at least in this PR, get rid of one of them. This PR was the idea of PastaPastaPasta, special thanks for the suggestion! ## Additional Information * There are two conventions being used for checking `nullptr`-ity of a pointer, `if (mn_activeman)` and `if (mn_activeman != nullptr)`. The former is used in initialization and RPC code due to existing conventions there ([source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/init.cpp#L1659-L1677), [source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/rpc/net.cpp#L942-L945), [source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/rpc/misc.cpp#L215-L218)). The latter is used whenever the value has to be passed as a `bool` (you cannot pass the implicit conversion to a `bool` argument without explicitly casting it) and in Dash-specific code where it is the prevalent convention ([source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/governance/governance.cpp#L125), [source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/coinjoin/client.cpp#L1064)). Unfortunately, that means this PR expresses the same thing sometimes in two different ways but this approach was taken so that reading is consistent within the same file. Codebase-wide harmonization is outside the scope of this PR. * Where `mn_activeman` isn't directly available, the result of the check is passed as an argument named `is_masternode` and/or set for the manager during its construction as `m_is_masternode` (`const bool`) as it is expected for the `CActiveMasternodeManager`'s presence or absence to remain as-is for the duration of the manager's lifetime. This does mean that some parts of the codebase check for `mn_activeman` while others check for {`m_`}`is_masternode`, which does reduce clarity while reading. Suggestions on improving this are welcomed. * One of the reasons this PR was made was to avoid having to deal the _possibility_ of `fMasternodeMode` or `fDisableGovernance` from desynchronizing from the behaviour of the managers it's suppose to influence. It's why additional assertions were placed in to make sure that `fMasternodeMode` and the existence of `mn_activeman` were always in sync ([source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/evo/mnauth.cpp#L137-L139), [source](https://github.com/dashpay/dash/blob/2dacfb08bdf02fdaf0740edac19435bfaa0e52d3/src/rpc/governance.cpp#L319-L320)). But removing the tracking global and relying on a manager's state itself prevents a potential desync, which is what this PR is aiming to do. ## Breaking Changes None expected. ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ Top commit has no ACKs. Tree-SHA512: 7861afd17c83b92af4c95b2841e9b0f676116eb3f234c4d0b1dcd3c20395452893e8ca3a17c7225389c8411dac80aeb5050f06a2ae35df5ec48998a571ef120c
2 parents e00f1ca + b4477e4 commit f9e123e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+206
-191
lines changed

src/coinjoin/client.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv)
3333
{
34-
if (fMasternodeMode) return {};
34+
if (m_is_masternode) return {};
3535
if (!m_mn_sync.IsBlockchainSynced()) return {};
3636

3737
if (msg_type == NetMsgType::DSQUEUE) {
@@ -133,7 +133,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
133133

134134
void CCoinJoinClientManager::ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
135135
{
136-
if (fMasternodeMode) return;
136+
if (m_is_masternode) return;
137137
if (!CCoinJoinClientOptions::IsEnabled()) return;
138138
if (!m_mn_sync.IsBlockchainSynced()) return;
139139

@@ -156,19 +156,20 @@ void CCoinJoinClientManager::ProcessMessage(CNode& peer, CConnman& connman, cons
156156
}
157157

158158
CCoinJoinClientSession::CCoinJoinClientSession(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
159-
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
159+
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :
160160
m_wallet(wallet),
161161
m_walletman(walletman),
162162
m_manager(*Assert(walletman.Get(wallet.GetName()))),
163163
m_dmnman(dmnman),
164164
m_mn_metaman(mn_metaman),
165165
m_mn_sync(mn_sync),
166-
m_queueman(queueman)
166+
m_queueman(queueman),
167+
m_is_masternode{is_masternode}
167168
{}
168169

169170
void CCoinJoinClientSession::ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
170171
{
171-
if (fMasternodeMode) return;
172+
if (m_is_masternode) return;
172173
if (!CCoinJoinClientOptions::IsEnabled()) return;
173174
if (!m_mn_sync.IsBlockchainSynced()) return;
174175

@@ -385,7 +386,7 @@ bool CCoinJoinClientManager::GetMixingMasternodesInfo(std::vector<CDeterministic
385386
//
386387
bool CCoinJoinClientSession::CheckTimeout()
387388
{
388-
if (fMasternodeMode) return false;
389+
if (m_is_masternode) return false;
389390

390391
if (nState == POOL_STATE_IDLE) return false;
391392

@@ -422,7 +423,7 @@ bool CCoinJoinClientSession::CheckTimeout()
422423
void CCoinJoinClientManager::CheckTimeout()
423424
{
424425
AssertLockNotHeld(cs_deqsessions);
425-
if (fMasternodeMode) return;
426+
if (m_is_masternode) return;
426427

427428
if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return;
428429

@@ -440,7 +441,7 @@ void CCoinJoinClientManager::CheckTimeout()
440441
//
441442
bool CCoinJoinClientSession::SendDenominate(const std::vector<std::pair<CTxDSIn, CTxOut> >& vecPSInOutPairsIn, CConnman& connman)
442443
{
443-
if (fMasternodeMode) {
444+
if (m_is_masternode) {
444445
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::SendDenominate -- CoinJoin from a Masternode is not supported currently.\n");
445446
return false;
446447
}
@@ -497,7 +498,7 @@ bool CCoinJoinClientSession::SendDenominate(const std::vector<std::pair<CTxDSIn,
497498
// Process incoming messages from Masternode updating the progress of mixing
498499
void CCoinJoinClientSession::ProcessPoolStateUpdate(CCoinJoinStatusUpdate psssup)
499500
{
500-
if (fMasternodeMode) return;
501+
if (m_is_masternode) return;
501502

502503
// do not update state when mixing client state is one of these
503504
if (nState == POOL_STATE_IDLE || nState == POOL_STATE_ERROR) return;
@@ -551,7 +552,7 @@ bool CCoinJoinClientSession::SignFinalTransaction(const CTxMemPool& mempool, con
551552
{
552553
if (!CCoinJoinClientOptions::IsEnabled()) return false;
553554

554-
if (fMasternodeMode) return false;
555+
if (m_is_masternode) return false;
555556
if (!mixingMasternode) return false;
556557

557558
LOCK(m_wallet.cs_wallet);
@@ -680,7 +681,7 @@ bool CCoinJoinClientSession::SignFinalTransaction(const CTxMemPool& mempool, con
680681
// mixing transaction was completed (failed or successful)
681682
void CCoinJoinClientSession::CompletedTransaction(PoolMessage nMessageID)
682683
{
683-
if (fMasternodeMode) return;
684+
if (m_is_masternode) return;
684685

685686
if (nMessageID == MSG_SUCCESS) {
686687
m_manager.UpdatedSuccessBlock();
@@ -697,7 +698,7 @@ void CCoinJoinClientSession::CompletedTransaction(PoolMessage nMessageID)
697698

698699
void CCoinJoinClientManager::UpdatedSuccessBlock()
699700
{
700-
if (fMasternodeMode) return;
701+
if (m_is_masternode) return;
701702
nCachedLastSuccessBlock = nCachedBlockHeight;
702703
}
703704

@@ -782,7 +783,7 @@ bool CCoinJoinClientManager::CheckAutomaticBackup()
782783
//
783784
bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, CTxMemPool& mempool, bool fDryRun)
784785
{
785-
if (fMasternodeMode) return false; // no client-side mixing on masternodes
786+
if (m_is_masternode) return false; // no client-side mixing on masternodes
786787
if (nState != POOL_STATE_IDLE) return false;
787788

788789
if (!m_mn_sync.IsBlockchainSynced()) {
@@ -962,7 +963,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, CTxMemPo
962963

963964
bool CCoinJoinClientManager::DoAutomaticDenominating(CConnman& connman, CTxMemPool& mempool, bool fDryRun)
964965
{
965-
if (fMasternodeMode) return false; // no client-side mixing on masternodes
966+
if (m_is_masternode) return false; // no client-side mixing on masternodes
966967
if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return false;
967968

968969
if (!m_mn_sync.IsBlockchainSynced()) {
@@ -991,7 +992,7 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(CConnman& connman, CTxMemPo
991992
AssertLockNotHeld(cs_deqsessions);
992993
LOCK(cs_deqsessions);
993994
if (int(deqSessions.size()) < CCoinJoinClientOptions::GetSessions()) {
994-
deqSessions.emplace_back(m_wallet, m_walletman, m_dmnman, m_mn_metaman, m_mn_sync, m_queueman);
995+
deqSessions.emplace_back(m_wallet, m_walletman, m_dmnman, m_mn_metaman, m_mn_sync, m_queueman, m_is_masternode);
995996
}
996997
for (auto& session : deqSessions) {
997998
if (!CheckAutomaticBackup()) return false;
@@ -1832,7 +1833,7 @@ void CCoinJoinClientManager::UpdatedBlockTip(const CBlockIndex* pindex)
18321833

18331834
void CCoinJoinClientQueueManager::DoMaintenance()
18341835
{
1835-
if (fMasternodeMode) return; // no client-side mixing on masternodes
1836+
if (m_is_masternode) return; // no client-side mixing on masternodes
18361837

18371838
if (!m_mn_sync.IsBlockchainSynced() || ShutdownRequested()) return;
18381839

@@ -1842,7 +1843,7 @@ void CCoinJoinClientQueueManager::DoMaintenance()
18421843
void CCoinJoinClientManager::DoMaintenance(CConnman& connman, CTxMemPool& mempool)
18431844
{
18441845
if (!CCoinJoinClientOptions::IsEnabled()) return;
1845-
if (fMasternodeMode) return; // no client-side mixing on masternodes
1846+
if (m_is_masternode) return; // no client-side mixing on masternodes
18461847

18471848
if (!m_mn_sync.IsBlockchainSynced() || ShutdownRequested()) return;
18481849

@@ -1893,7 +1894,7 @@ void CCoinJoinClientManager::GetJsonInfo(UniValue& obj) const
18931894
void CoinJoinWalletManager::Add(CWallet& wallet) {
18941895
m_wallet_manager_map.try_emplace(
18951896
wallet.GetName(),
1896-
std::make_unique<CCoinJoinClientManager>(wallet, *this, m_dmnman, m_mn_metaman, m_mn_sync, m_queueman)
1897+
std::make_unique<CCoinJoinClientManager>(wallet, *this, m_dmnman, m_mn_metaman, m_mn_sync, m_queueman, m_is_masternode)
18971898
);
18981899
g_wallet_init_interface.InitCoinJoinSettings(*this);
18991900
}

src/coinjoin/client.h

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ class CoinJoinWalletManager {
7474

7575
public:
7676
CoinJoinWalletManager(CConnman& connman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
77-
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman)
78-
: m_connman(connman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mempool(mempool), m_mn_sync(mn_sync), m_queueman(queueman) {}
77+
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode)
78+
: m_connman(connman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mempool(mempool), m_mn_sync(mn_sync), m_queueman(queueman),
79+
m_is_masternode{is_masternode}
80+
{}
7981

8082
~CoinJoinWalletManager() {
8183
for (auto& [wallet_name, cj_man] : m_wallet_manager_map) {
@@ -101,6 +103,7 @@ class CoinJoinWalletManager {
101103
const CMasternodeSync& m_mn_sync;
102104
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
103105

106+
const bool m_is_masternode;
104107
wallet_name_cjman_map m_wallet_manager_map;
105108
};
106109

@@ -115,6 +118,9 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
115118
const CMasternodeSync& m_mn_sync;
116119
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
117120

121+
// Track node type
122+
const bool m_is_masternode;
123+
118124
std::vector<COutPoint> vecOutPointLocked;
119125

120126
bilingual_str strLastMessage;
@@ -162,7 +168,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
162168

163169
public:
164170
explicit CCoinJoinClientSession(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
165-
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman);
171+
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode);
166172

167173
void ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);
168174

@@ -197,12 +203,14 @@ class CCoinJoinClientQueueManager : public CCoinJoinBaseManager
197203
CDeterministicMNManager& m_dmnman;
198204
CMasternodeMetaMan& m_mn_metaman;
199205
const CMasternodeSync& m_mn_sync;
206+
200207
mutable Mutex cs_ProcessDSQueue;
208+
const bool m_is_masternode;
201209

202210
public:
203211
explicit CCoinJoinClientQueueManager(CConnman& _connman, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
204-
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync) :
205-
connman(_connman), m_walletman(walletman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mn_sync(mn_sync) {};
212+
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync, bool is_masternode) :
213+
connman(_connman), m_walletman(walletman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mn_sync(mn_sync), m_is_masternode{is_masternode} {};
206214

207215
PeerMsgRet ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_vecqueue);
208216
PeerMsgRet ProcessDSQueue(const CNode& peer, CDataStream& vRecv);
@@ -221,6 +229,9 @@ class CCoinJoinClientManager
221229
const CMasternodeSync& m_mn_sync;
222230
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
223231

232+
// Track node type
233+
const bool m_is_masternode;
234+
224235
// Keep track of the used Masternodes
225236
std::vector<COutPoint> vecMasternodesUsed;
226237

@@ -252,8 +263,9 @@ class CCoinJoinClientManager
252263

253264
explicit CCoinJoinClientManager(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
254265
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
255-
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
256-
m_wallet(wallet), m_walletman(walletman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mn_sync(mn_sync), m_queueman(queueman) {}
266+
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :
267+
m_wallet(wallet), m_walletman(walletman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mn_sync(mn_sync), m_queueman(queueman),
268+
m_is_masternode{is_masternode} {}
257269

258270
void ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_deqsessions);
259271

src/coinjoin/context.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ CJContext::CJContext(CChainState& chainstate, CConnman& connman, CDeterministicM
1414
const std::unique_ptr<PeerManager>& peerman, bool relay_txes) :
1515
dstxman{std::make_unique<CDSTXManager>()},
1616
#ifdef ENABLE_WALLET
17-
walletman{std::make_unique<CoinJoinWalletManager>(connman, dmnman, mn_metaman, mempool, mn_sync, queueman)},
18-
queueman {relay_txes ? std::make_unique<CCoinJoinClientQueueManager>(connman, *walletman, dmnman, mn_metaman, mn_sync) : nullptr},
17+
walletman{std::make_unique<CoinJoinWalletManager>(connman, dmnman, mn_metaman, mempool, mn_sync, queueman, /* is_masternode = */ mn_activeman != nullptr)},
18+
queueman {relay_txes ? std::make_unique<CCoinJoinClientQueueManager>(connman, *walletman, dmnman, mn_metaman, mn_sync, /* is_masternode = */ mn_activeman != nullptr) : nullptr},
1919
#endif // ENABLE_WALLET
2020
server{std::make_unique<CCoinJoinServer>(chainstate, connman, dmnman, *dstxman, mn_metaman, mempool, mn_activeman, mn_sync, peerman)}
2121
{}

src/coinjoin/server.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
PeerMsgRet CCoinJoinServer::ProcessMessage(CNode& peer, std::string_view msg_type, CDataStream& vRecv)
2929
{
30-
if (!fMasternodeMode) return {};
30+
if (!m_mn_activeman) return {};
3131
if (!m_mn_sync.IsBlockchainSynced()) return {};
3232

3333
if (msg_type == NetMsgType::DSACCEPT) {
@@ -249,7 +249,7 @@ void CCoinJoinServer::SetNull()
249249
//
250250
void CCoinJoinServer::CheckPool()
251251
{
252-
if (!fMasternodeMode) return;
252+
if (!m_mn_activeman) return;
253253

254254
if (int entries = GetEntriesCount(); entries != 0) LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CheckPool -- entries count %lu\n", entries);
255255

@@ -312,9 +312,7 @@ void CCoinJoinServer::CreateFinalTransaction()
312312
void CCoinJoinServer::CommitFinalTransaction()
313313
{
314314
AssertLockNotHeld(cs_coinjoin);
315-
if (!fMasternodeMode) return; // check and relay final tx only on masternode
316-
317-
assert(m_mn_activeman);
315+
if (!m_mn_activeman) return; // check and relay final tx only on masternode
318316

319317
CTransactionRef finalTransaction = WITH_LOCK(cs_coinjoin, return MakeTransactionRef(finalMutableTransaction));
320318
uint256 hashTx = finalTransaction->GetHash();
@@ -377,7 +375,7 @@ void CCoinJoinServer::CommitFinalTransaction()
377375
void CCoinJoinServer::ChargeFees() const
378376
{
379377
AssertLockNotHeld(cs_coinjoin);
380-
if (!fMasternodeMode) return;
378+
if (!m_mn_activeman) return;
381379

382380
//we don't need to charge collateral for every offence.
383381
if (GetRandInt(100) > 33) return;
@@ -445,7 +443,7 @@ void CCoinJoinServer::ChargeFees() const
445443
*/
446444
void CCoinJoinServer::ChargeRandomFees() const
447445
{
448-
if (!fMasternodeMode) return;
446+
if (!m_mn_activeman) return;
449447

450448
for (const auto& txCollateral : vecSessionCollaterals) {
451449
if (GetRandInt(100) > 10) return;
@@ -467,7 +465,7 @@ void CCoinJoinServer::ConsumeCollateral(const CTransactionRef& txref) const
467465

468466
bool CCoinJoinServer::HasTimedOut() const
469467
{
470-
if (!fMasternodeMode) return false;
468+
if (!m_mn_activeman) return false;
471469

472470
if (nState == POOL_STATE_IDLE) return false;
473471

@@ -481,7 +479,7 @@ bool CCoinJoinServer::HasTimedOut() const
481479
//
482480
void CCoinJoinServer::CheckTimeout()
483481
{
484-
if (!fMasternodeMode) return;
482+
if (!m_mn_activeman) return;
485483

486484
CheckQueue();
487485

@@ -501,9 +499,7 @@ void CCoinJoinServer::CheckTimeout()
501499
*/
502500
void CCoinJoinServer::CheckForCompleteQueue()
503501
{
504-
if (!fMasternodeMode) return;
505-
506-
assert(m_mn_activeman);
502+
if (!m_mn_activeman) return;
507503

508504
if (nState == POOL_STATE_QUEUE && IsSessionReady()) {
509505
SetState(POOL_STATE_ACCEPTING_ENTRIES);
@@ -570,7 +566,7 @@ bool CCoinJoinServer::IsInputScriptSigValid(const CTxIn& txin) const
570566
bool CCoinJoinServer::AddEntry(const CCoinJoinEntry& entry, PoolMessage& nMessageIDRet)
571567
{
572568
AssertLockNotHeld(cs_coinjoin);
573-
if (!fMasternodeMode) return false;
569+
if (!m_mn_activeman) return false;
574570

575571
if (size_t(GetEntriesCount()) >= vecSessionCollaterals.size()) {
576572
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- ERROR: entries is full!\n", __func__);
@@ -679,7 +675,7 @@ bool CCoinJoinServer::IsSignaturesComplete() const
679675

680676
bool CCoinJoinServer::IsAcceptableDSA(const CCoinJoinAccept& dsa, PoolMessage& nMessageIDRet) const
681677
{
682-
if (!fMasternodeMode) return false;
678+
if (!m_mn_activeman) return false;
683679

684680
// is denom even something legit?
685681
if (!CoinJoin::IsValidDenomination(dsa.nDenom)) {
@@ -700,9 +696,7 @@ bool CCoinJoinServer::IsAcceptableDSA(const CCoinJoinAccept& dsa, PoolMessage& n
700696

701697
bool CCoinJoinServer::CreateNewSession(const CCoinJoinAccept& dsa, PoolMessage& nMessageIDRet)
702698
{
703-
if (!fMasternodeMode || nSessionID != 0) return false;
704-
705-
assert(m_mn_activeman);
699+
if (!m_mn_activeman || nSessionID != 0) return false;
706700

707701
// new session can only be started in idle mode
708702
if (nState != POOL_STATE_IDLE) {
@@ -744,7 +738,7 @@ bool CCoinJoinServer::CreateNewSession(const CCoinJoinAccept& dsa, PoolMessage&
744738

745739
bool CCoinJoinServer::AddUserToExistingSession(const CCoinJoinAccept& dsa, PoolMessage& nMessageIDRet)
746740
{
747-
if (!fMasternodeMode || nSessionID == 0 || IsSessionReady()) return false;
741+
if (!m_mn_activeman || nSessionID == 0 || IsSessionReady()) return false;
748742

749743
if (!IsAcceptableDSA(dsa, nMessageIDRet)) {
750744
return false;
@@ -880,7 +874,7 @@ void CCoinJoinServer::RelayCompletedTransaction(PoolMessage nMessageID)
880874

881875
void CCoinJoinServer::SetState(PoolState nStateNew)
882876
{
883-
if (!fMasternodeMode) return;
877+
if (!m_mn_activeman) return;
884878

885879
if (nStateNew == POOL_STATE_ERROR) {
886880
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::SetState -- Can't set state to ERROR as a Masternode. \n");
@@ -894,7 +888,7 @@ void CCoinJoinServer::SetState(PoolState nStateNew)
894888

895889
void CCoinJoinServer::DoMaintenance()
896890
{
897-
if (!fMasternodeMode) return; // only run on masternodes
891+
if (!m_mn_activeman) return; // only run on masternodes
898892
if (!m_mn_sync.IsBlockchainSynced()) return;
899893
if (ShutdownRequested()) return;
900894

src/dsnotificationinterface.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
9797

9898
m_llmq_ctx->qman->UpdatedBlockTip(pindexNew, fInitialDownload);
9999
m_llmq_ctx->qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload);
100-
m_llmq_ctx->ehfSignalsHandler->UpdatedBlockTip(pindexNew);
100+
m_llmq_ctx->ehfSignalsHandler->UpdatedBlockTip(pindexNew, /* is_masternode = */ m_mn_activeman != nullptr);
101101

102-
if (!fDisableGovernance) m_govman.UpdatedBlockTip(pindexNew, m_connman, m_peerman, m_mn_activeman);
102+
if (m_govman.IsValid()) {
103+
m_govman.UpdatedBlockTip(pindexNew, m_connman, m_peerman, m_mn_activeman);
104+
}
103105
}
104106

105107
void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx, int64_t nAcceptTime)

0 commit comments

Comments
 (0)