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