mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: add CActiveMasternodeManager NodeContext alias, use in RPC
This commit is contained in:
parent
44beb941cb
commit
f171c24a29
@ -369,7 +369,8 @@ void PrepareShutdown(NodeContext& node)
|
||||
pdsNotificationInterface = nullptr;
|
||||
}
|
||||
if (fMasternodeMode) {
|
||||
UnregisterValidationInterface(::activeMasternodeManager.get());
|
||||
UnregisterValidationInterface(node.mn_activeman);
|
||||
node.mn_activeman = nullptr;
|
||||
::activeMasternodeManager.reset();
|
||||
}
|
||||
|
||||
@ -1854,7 +1855,8 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
{
|
||||
// Create and register activeMasternodeManager, will init later in ThreadImport
|
||||
::activeMasternodeManager = std::make_unique<CActiveMasternodeManager>(keyOperator, *node.connman, ::deterministicMNManager);
|
||||
RegisterValidationInterface(::activeMasternodeManager.get());
|
||||
node.mn_activeman = ::activeMasternodeManager.get();
|
||||
RegisterValidationInterface(node.mn_activeman);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
class ArgsManager;
|
||||
class BanMan;
|
||||
class CActiveMasternodeManager;
|
||||
class CAddrMan;
|
||||
class CBlockPolicyEstimator;
|
||||
class CConnman;
|
||||
@ -79,6 +80,7 @@ struct NodeContext {
|
||||
std::unique_ptr<CNetFulfilledRequestManager> netfulfilledman;
|
||||
std::unique_ptr<CSporkManager> sporkman;
|
||||
std::unique_ptr<LLMQContext> llmq_ctx;
|
||||
CActiveMasternodeManager* mn_activeman{nullptr};
|
||||
CDeterministicMNManager* dmnman{nullptr};
|
||||
CMasternodeMetaMan* mn_metaman{nullptr};
|
||||
CMasternodeSync* mn_sync{nullptr};
|
||||
|
@ -316,17 +316,21 @@ static UniValue gobject_submit(const JSONRPCRequest& request)
|
||||
|
||||
auto mnList = node.dmnman->GetListAtChainTip();
|
||||
|
||||
bool fMnFound{false};
|
||||
if (fMasternodeMode) {
|
||||
LOCK(::activeMasternodeManager->cs);
|
||||
fMnFound = mnList.HasValidMNByCollateral(::activeMasternodeManager->GetOutPoint());
|
||||
CHECK_NONFATAL(node.mn_activeman);
|
||||
|
||||
LOCK(node.mn_activeman->cs);
|
||||
const bool fMnFound = mnList.HasValidMNByCollateral(node.mn_activeman->GetOutPoint());
|
||||
|
||||
LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = %s, outpoint = %s, params.size() = %lld, fMnFound = %d\n",
|
||||
::activeMasternodeManager->GetPubKey().ToString(::activeMasternodeManager->IsLegacy()),
|
||||
::activeMasternodeManager->GetOutPoint().ToStringShort(), request.params.size(), fMnFound);
|
||||
node.mn_activeman->GetPubKey().ToString(node.mn_activeman->IsLegacy()),
|
||||
node.mn_activeman->GetOutPoint().ToStringShort(),
|
||||
request.params.size(),
|
||||
fMnFound);
|
||||
} else {
|
||||
LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = N/A, outpoint = N/A, params.size() = %lld, fMnFound = %d\n",
|
||||
request.params.size(), fMnFound);
|
||||
request.params.size(),
|
||||
false);
|
||||
}
|
||||
|
||||
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
|
||||
|
@ -262,16 +262,17 @@ static UniValue masternode_status(const JSONRPCRequest& request)
|
||||
}
|
||||
|
||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
CHECK_NONFATAL(node.mn_activeman);
|
||||
|
||||
UniValue mnObj(UniValue::VOBJ);
|
||||
CDeterministicMNCPtr dmn;
|
||||
{
|
||||
LOCK(::activeMasternodeManager->cs);
|
||||
LOCK(node.mn_activeman->cs);
|
||||
|
||||
// keep compatibility with legacy status for now (might get deprecated/removed later)
|
||||
mnObj.pushKV("outpoint", ::activeMasternodeManager->GetOutPoint().ToStringShort());
|
||||
mnObj.pushKV("service", ::activeMasternodeManager->GetService().ToString());
|
||||
dmn = node.dmnman->GetListAtChainTip().GetMN(::activeMasternodeManager->GetProTxHash());
|
||||
mnObj.pushKV("outpoint", node.mn_activeman->GetOutPoint().ToStringShort());
|
||||
mnObj.pushKV("service", node.mn_activeman->GetService().ToString());
|
||||
dmn = node.dmnman->GetListAtChainTip().GetMN(node.mn_activeman->GetProTxHash());
|
||||
}
|
||||
if (dmn) {
|
||||
mnObj.pushKV("proTxHash", dmn->proTxHash.ToString());
|
||||
@ -280,8 +281,8 @@ static UniValue masternode_status(const JSONRPCRequest& request)
|
||||
mnObj.pushKV("collateralIndex", (int)dmn->collateralOutpoint.n);
|
||||
mnObj.pushKV("dmnState", dmn->pdmnState->ToJson(dmn->nType));
|
||||
}
|
||||
mnObj.pushKV("state", activeMasternodeManager->GetStateString());
|
||||
mnObj.pushKV("status", activeMasternodeManager->GetStatus());
|
||||
mnObj.pushKV("state", node.mn_activeman->GetStateString());
|
||||
mnObj.pushKV("status", node.mn_activeman->GetStatus());
|
||||
|
||||
return mnObj;
|
||||
}
|
||||
|
@ -275,7 +275,8 @@ static void quorum_dkgstatus_help(const JSONRPCRequest& request)
|
||||
}.Check(request);
|
||||
}
|
||||
|
||||
static UniValue quorum_dkgstatus(const JSONRPCRequest& request, CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CSporkManager& sporkman, const LLMQContext& llmq_ctx)
|
||||
static UniValue quorum_dkgstatus(const JSONRPCRequest& request, CDeterministicMNManager& dmnman, const CActiveMasternodeManager* mn_activeman,
|
||||
const ChainstateManager& chainman, const CSporkManager& sporkman, const LLMQContext& llmq_ctx)
|
||||
{
|
||||
quorum_dkgstatus_help(request);
|
||||
|
||||
@ -295,9 +296,11 @@ static UniValue quorum_dkgstatus(const JSONRPCRequest& request, CDeterministicMN
|
||||
CBlockIndex* pindexTip = WITH_LOCK(cs_main, return chainman.ActiveChain().Tip());
|
||||
int tipHeight = pindexTip->nHeight;
|
||||
|
||||
const uint256 proTxHash = fMasternodeMode ?
|
||||
WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()) :
|
||||
uint256();
|
||||
const uint256 proTxHash = [&mn_activeman]() {
|
||||
if (!fMasternodeMode) return uint256();
|
||||
CHECK_NONFATAL(mn_activeman);
|
||||
return WITH_LOCK(mn_activeman->cs, return mn_activeman->GetProTxHash());
|
||||
}();
|
||||
|
||||
UniValue minableCommitments(UniValue::VARR);
|
||||
UniValue quorumArrConnections(UniValue::VARR);
|
||||
@ -881,7 +884,7 @@ static UniValue _quorum(const JSONRPCRequest& request)
|
||||
} else if (command == "quorumdkginfo") {
|
||||
return quorum_dkginfo(new_request, llmq_ctx, chainman);
|
||||
} else if (command == "quorumdkgstatus") {
|
||||
return quorum_dkgstatus(new_request, *node.dmnman, chainman, *node.sporkman, llmq_ctx);
|
||||
return quorum_dkgstatus(new_request, *node.dmnman, node.mn_activeman, chainman, *node.sporkman, llmq_ctx);
|
||||
} else if (command == "quorummemberof") {
|
||||
return quorum_memberof(new_request, chainman, node, llmq_ctx);
|
||||
} else if (command == "quorumsign" || command == "quorumverify" || command == "quorumhasrecsig" || command == "quorumgetrecsig" || command == "quorumisconflicting") {
|
||||
|
Loading…
Reference in New Issue
Block a user