mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +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;
|
didConnect = false;
|
||||||
|
|
||||||
if (!fNetworkActive || !mn_sync.IsBlockchainSynced())
|
if (!fNetworkActive || !m_masternode_thread_active || !mn_sync.IsBlockchainSynced()) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
std::set<CService> connectedNodes;
|
std::set<CService> connectedNodes;
|
||||||
std::map<uint256 /*proTxHash*/, bool /*fInbound*/> connectedProRegTxHashes;
|
std::map<uint256 /*proTxHash*/, bool /*fInbound*/> connectedProRegTxHashes;
|
||||||
|
@ -1223,6 +1223,8 @@ public:
|
|||||||
bool GetNetworkActive() const { return fNetworkActive; };
|
bool GetNetworkActive() const { return fNetworkActive; };
|
||||||
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
|
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
|
||||||
void SetNetworkActive(bool active, CMasternodeSync* const mn_sync);
|
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; }
|
SocketEventsMode GetSocketEventsMode() const { return socketEventsMode; }
|
||||||
|
|
||||||
enum class MasternodeConn {
|
enum class MasternodeConn {
|
||||||
@ -1721,6 +1723,7 @@ private:
|
|||||||
|
|
||||||
std::vector<ListenSocket> vhListenSocket;
|
std::vector<ListenSocket> vhListenSocket;
|
||||||
std::atomic<bool> fNetworkActive{true};
|
std::atomic<bool> fNetworkActive{true};
|
||||||
|
std::atomic<bool> m_masternode_thread_active{true};
|
||||||
bool fAddressesInitialized{false};
|
bool fAddressesInitialized{false};
|
||||||
AddrMan& addrman;
|
AddrMan& addrman;
|
||||||
const NetGroupManager& m_netgroupman;
|
const NetGroupManager& m_netgroupman;
|
||||||
|
@ -175,6 +175,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "prioritisetransaction", 1, "fee_delta" },
|
{ "prioritisetransaction", 1, "fee_delta" },
|
||||||
{ "setban", 2, "bantime" },
|
{ "setban", 2, "bantime" },
|
||||||
{ "setban", 3, "absolute" },
|
{ "setban", 3, "absolute" },
|
||||||
|
{ "setmnthreadactive", 0, "state" },
|
||||||
{ "setnetworkactive", 0, "state" },
|
{ "setnetworkactive", 0, "state" },
|
||||||
{ "setcoinjoinrounds", 0, "rounds" },
|
{ "setcoinjoinrounds", 0, "rounds" },
|
||||||
{ "setcoinjoinamount", 0, "amount" },
|
{ "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)
|
void RegisterNetRPCCommands(CRPCTable &t)
|
||||||
{
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@ -1042,6 +1068,7 @@ static const CRPCCommand commands[] =
|
|||||||
|
|
||||||
{ "hidden", &addconnection, },
|
{ "hidden", &addconnection, },
|
||||||
{ "hidden", &addpeeraddress, },
|
{ "hidden", &addpeeraddress, },
|
||||||
|
{ "hidden", &setmnthreadactive },
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
for (const auto& c : commands) {
|
for (const auto& c : commands) {
|
||||||
|
@ -150,6 +150,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
|
|||||||
"reconsiderblock",
|
"reconsiderblock",
|
||||||
"scantxoutset",
|
"scantxoutset",
|
||||||
"sendrawtransaction",
|
"sendrawtransaction",
|
||||||
|
"setmnthreadactive",
|
||||||
"setmocktime",
|
"setmocktime",
|
||||||
"setnetworkactive",
|
"setnetworkactive",
|
||||||
"signmessagewithprivkey",
|
"signmessagewithprivkey",
|
||||||
|
Loading…
Reference in New Issue
Block a user