-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: consolidate activeMasternodeInfo{Cs} into CActiveMasternodeManager, create NodeContext alias, reduce globals usage #5940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9a3c5a3
b8c1f01
e5295de
3827355
3eb931b
33702ac
1b516ce
fbc7836
73cef4f
44beb94
f171c24
5e0f777
136e445
815e4f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -692,14 +692,14 @@ std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigg | |
| } | ||
|
|
||
| { | ||
| LOCK(activeMasternodeInfoCs); | ||
| if (mn_payees.front()->proTxHash != activeMasternodeInfo.proTxHash) { | ||
| LOCK(::activeMasternodeManager->cs); | ||
| if (mn_payees.front()->proTxHash != ::activeMasternodeManager->GetProTxHash()) { | ||
| LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s we are not the payee, skipping\n", __func__); | ||
| return std::nullopt; | ||
| } | ||
| gov_sb.SetMasternodeOutpoint(activeMasternodeInfo.outpoint); | ||
| gov_sb.Sign( *activeMasternodeInfo.blsKeyOperator); | ||
| } // activeMasternodeInfoCs | ||
| gov_sb.SetMasternodeOutpoint(::activeMasternodeManager->GetOutPoint()); | ||
| } // ::activeMasternodeManager->cs | ||
| gov_sb.Sign(*::activeMasternodeManager); | ||
|
|
||
| if (std::string strError; !gov_sb.IsValidLocally(m_dmnman->GetListAtChainTip(), strError, true)) { | ||
| LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Created trigger is invalid:%s\n", __func__, strError); | ||
|
|
@@ -719,7 +719,8 @@ std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigg | |
| void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGovernanceObject>& trigger_opt, CConnman& connman) | ||
| { | ||
| // only active masternodes can vote on triggers | ||
| if (!fMasternodeMode || WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash.IsNull())) return; | ||
| if (!fMasternodeMode) return; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code is equivalent due to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 please revert
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was a stylistic choice to keep the check for masternode mode and the check that relies on the previous check that masternode mode is active on separate lines. Reading the function without context gives the impression those are two separate conditions being checked while the second condition itself relies on the first condition's result.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clang-tidy will be annoyed about two if blocks next to each other with duplicate bodies |
||
| if (WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash().IsNull())) return; | ||
|
|
||
| LOCK2(cs_main, cs); | ||
|
|
||
|
|
@@ -762,9 +763,9 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover | |
|
|
||
| bool CGovernanceManager::VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman) | ||
| { | ||
| CGovernanceVote vote(WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.outpoint), nHash, VOTE_SIGNAL_FUNDING, outcome); | ||
| CGovernanceVote vote(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetOutPoint()), nHash, VOTE_SIGNAL_FUNDING, outcome); | ||
| vote.SetTime(GetAdjustedTime()); | ||
| vote.Sign(WITH_LOCK(activeMasternodeInfoCs, return *activeMasternodeInfo.blsKeyOperator)); | ||
| vote.Sign(*::activeMasternodeManager); | ||
|
|
||
| CGovernanceException exception; | ||
| if (!ProcessVoteAndRelay(vote, exception, connman)) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.