mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
feat(rpc): introduce setmnthreadactive
(regtest-only)
This commit is contained in:
parent
52928c548e
commit
e2ed82a7ae
@ -3486,8 +3486,7 @@ void CConnman::ThreadOpenMasternodeConnections(CDeterministicMNManager& dmnman,
|
||||
|
||||
didConnect = false;
|
||||
|
||||
if (!fNetworkActive || !mn_sync.IsBlockchainSynced())
|
||||
continue;
|
||||
if (!fNetworkActive || !m_masternode_thread_active || !mn_sync.IsBlockchainSynced()) continue;
|
||||
|
||||
std::set<CService> connectedNodes;
|
||||
std::map<uint256 /*proTxHash*/, bool /*fInbound*/> connectedProRegTxHashes;
|
||||
|
@ -1223,6 +1223,8 @@ public:
|
||||
bool GetNetworkActive() const { return fNetworkActive; };
|
||||
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
|
||||
void SetNetworkActive(bool active, CMasternodeSync* const mn_sync);
|
||||
bool GetMasternodeThreadActive() const { return m_masternode_thread_active; };
|
||||
void SetMasternodeThreadActive(bool active) { m_masternode_thread_active = active; };
|
||||
SocketEventsMode GetSocketEventsMode() const { return socketEventsMode; }
|
||||
|
||||
enum class MasternodeConn {
|
||||
@ -1721,6 +1723,7 @@ private:
|
||||
|
||||
std::vector<ListenSocket> vhListenSocket;
|
||||
std::atomic<bool> fNetworkActive{true};
|
||||
std::atomic<bool> m_masternode_thread_active{true};
|
||||
bool fAddressesInitialized{false};
|
||||
AddrMan& addrman;
|
||||
const NetGroupManager& m_netgroupman;
|
||||
|
@ -175,6 +175,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "prioritisetransaction", 1, "fee_delta" },
|
||||
{ "setban", 2, "bantime" },
|
||||
{ "setban", 3, "absolute" },
|
||||
{ "setmnthreadactive", 0, "state" },
|
||||
{ "setnetworkactive", 0, "state" },
|
||||
{ "setcoinjoinrounds", 0, "rounds" },
|
||||
{ "setcoinjoinamount", 0, "amount" },
|
||||
|
@ -1019,6 +1019,32 @@ static RPCHelpMan addpeeraddress()
|
||||
};
|
||||
}
|
||||
|
||||
static RPCHelpMan setmnthreadactive()
|
||||
{
|
||||
return RPCHelpMan{"setmnthreadactive",
|
||||
"\nDisable/enable automatic masternode connections thread activity.\n",
|
||||
{
|
||||
{"state", RPCArg::Type::BOOL, RPCArg::Optional::NO, "true to enable the thread, false to disable"},
|
||||
},
|
||||
RPCResult{RPCResult::Type::BOOL, "", "The value that was passed in"},
|
||||
RPCExamples{""},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
|
||||
if (Params().NetworkIDString() != CBaseChainParams::REGTEST) {
|
||||
throw std::runtime_error("setmnthreadactive is for regression testing (-regtest mode) only.");
|
||||
}
|
||||
|
||||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
CConnman& connman = EnsureConnman(node);
|
||||
|
||||
connman.SetMasternodeThreadActive(request.params[0].get_bool());
|
||||
|
||||
return connman.GetMasternodeThreadActive();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
void RegisterNetRPCCommands(CRPCTable &t)
|
||||
{
|
||||
// clang-format off
|
||||
@ -1042,6 +1068,7 @@ static const CRPCCommand commands[] =
|
||||
|
||||
{ "hidden", &addconnection, },
|
||||
{ "hidden", &addpeeraddress, },
|
||||
{ "hidden", &setmnthreadactive },
|
||||
};
|
||||
// clang-format on
|
||||
for (const auto& c : commands) {
|
||||
|
@ -150,6 +150,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
|
||||
"reconsiderblock",
|
||||
"scantxoutset",
|
||||
"sendrawtransaction",
|
||||
"setmnthreadactive",
|
||||
"setmocktime",
|
||||
"setnetworkactive",
|
||||
"signmessagewithprivkey",
|
||||
|
Loading…
Reference in New Issue
Block a user