mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
RPC: add facility to enable RPCs to run outside cs_main, wallet locks
Use with 'stop' and 'help' RPCs. This provides a facility to individually evaluate the locking for an RPC, and potentially make it more parallel.
This commit is contained in:
parent
5f2b41d54d
commit
0e1d3551da
@ -191,62 +191,62 @@ Value stop(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
|
|
||||||
static const CRPCCommand vRPCCommands[] =
|
static const CRPCCommand vRPCCommands[] =
|
||||||
{ // name function safe mode?
|
{ // name function safemd unlocked
|
||||||
// ------------------------ ----------------------- ----------
|
// ------------------------ ----------------------- ------ --------
|
||||||
{ "help", &help, true },
|
{ "help", &help, true, true },
|
||||||
{ "stop", &stop, true },
|
{ "stop", &stop, true, true },
|
||||||
{ "getblockcount", &getblockcount, true },
|
{ "getblockcount", &getblockcount, true, false },
|
||||||
{ "getconnectioncount", &getconnectioncount, true },
|
{ "getconnectioncount", &getconnectioncount, true, false },
|
||||||
{ "getpeerinfo", &getpeerinfo, true },
|
{ "getpeerinfo", &getpeerinfo, true, false },
|
||||||
{ "getdifficulty", &getdifficulty, true },
|
{ "getdifficulty", &getdifficulty, true, false },
|
||||||
{ "getgenerate", &getgenerate, true },
|
{ "getgenerate", &getgenerate, true, false },
|
||||||
{ "setgenerate", &setgenerate, true },
|
{ "setgenerate", &setgenerate, true, false },
|
||||||
{ "gethashespersec", &gethashespersec, true },
|
{ "gethashespersec", &gethashespersec, true, false },
|
||||||
{ "getinfo", &getinfo, true },
|
{ "getinfo", &getinfo, true, false },
|
||||||
{ "getmininginfo", &getmininginfo, true },
|
{ "getmininginfo", &getmininginfo, true, false },
|
||||||
{ "getnewaddress", &getnewaddress, true },
|
{ "getnewaddress", &getnewaddress, true, false },
|
||||||
{ "getaccountaddress", &getaccountaddress, true },
|
{ "getaccountaddress", &getaccountaddress, true, false },
|
||||||
{ "setaccount", &setaccount, true },
|
{ "setaccount", &setaccount, true, false },
|
||||||
{ "getaccount", &getaccount, false },
|
{ "getaccount", &getaccount, false, false },
|
||||||
{ "getaddressesbyaccount", &getaddressesbyaccount, true },
|
{ "getaddressesbyaccount", &getaddressesbyaccount, true, false },
|
||||||
{ "sendtoaddress", &sendtoaddress, false },
|
{ "sendtoaddress", &sendtoaddress, false, false },
|
||||||
{ "getreceivedbyaddress", &getreceivedbyaddress, false },
|
{ "getreceivedbyaddress", &getreceivedbyaddress, false, false },
|
||||||
{ "getreceivedbyaccount", &getreceivedbyaccount, false },
|
{ "getreceivedbyaccount", &getreceivedbyaccount, false, false },
|
||||||
{ "listreceivedbyaddress", &listreceivedbyaddress, false },
|
{ "listreceivedbyaddress", &listreceivedbyaddress, false, false },
|
||||||
{ "listreceivedbyaccount", &listreceivedbyaccount, false },
|
{ "listreceivedbyaccount", &listreceivedbyaccount, false, false },
|
||||||
{ "backupwallet", &backupwallet, true },
|
{ "backupwallet", &backupwallet, true, false },
|
||||||
{ "keypoolrefill", &keypoolrefill, true },
|
{ "keypoolrefill", &keypoolrefill, true, false },
|
||||||
{ "walletpassphrase", &walletpassphrase, true },
|
{ "walletpassphrase", &walletpassphrase, true, false },
|
||||||
{ "walletpassphrasechange", &walletpassphrasechange, false },
|
{ "walletpassphrasechange", &walletpassphrasechange, false, false },
|
||||||
{ "walletlock", &walletlock, true },
|
{ "walletlock", &walletlock, true, false },
|
||||||
{ "encryptwallet", &encryptwallet, false },
|
{ "encryptwallet", &encryptwallet, false, false },
|
||||||
{ "validateaddress", &validateaddress, true },
|
{ "validateaddress", &validateaddress, true, false },
|
||||||
{ "getbalance", &getbalance, false },
|
{ "getbalance", &getbalance, false, false },
|
||||||
{ "move", &movecmd, false },
|
{ "move", &movecmd, false, false },
|
||||||
{ "sendfrom", &sendfrom, false },
|
{ "sendfrom", &sendfrom, false, false },
|
||||||
{ "sendmany", &sendmany, false },
|
{ "sendmany", &sendmany, false, false },
|
||||||
{ "addmultisigaddress", &addmultisigaddress, false },
|
{ "addmultisigaddress", &addmultisigaddress, false, false },
|
||||||
{ "getrawmempool", &getrawmempool, true },
|
{ "getrawmempool", &getrawmempool, true, false },
|
||||||
{ "getblock", &getblock, false },
|
{ "getblock", &getblock, false, false },
|
||||||
{ "getblockhash", &getblockhash, false },
|
{ "getblockhash", &getblockhash, false, false },
|
||||||
{ "gettransaction", &gettransaction, false },
|
{ "gettransaction", &gettransaction, false, false },
|
||||||
{ "listtransactions", &listtransactions, false },
|
{ "listtransactions", &listtransactions, false, false },
|
||||||
{ "signmessage", &signmessage, false },
|
{ "signmessage", &signmessage, false, false },
|
||||||
{ "verifymessage", &verifymessage, false },
|
{ "verifymessage", &verifymessage, false, false },
|
||||||
{ "getwork", &getwork, true },
|
{ "getwork", &getwork, true, false },
|
||||||
{ "listaccounts", &listaccounts, false },
|
{ "listaccounts", &listaccounts, false, false },
|
||||||
{ "settxfee", &settxfee, false },
|
{ "settxfee", &settxfee, false, false },
|
||||||
{ "getblocktemplate", &getblocktemplate, true },
|
{ "getblocktemplate", &getblocktemplate, true, false },
|
||||||
{ "submitblock", &submitblock, false },
|
{ "submitblock", &submitblock, false, false },
|
||||||
{ "listsinceblock", &listsinceblock, false },
|
{ "listsinceblock", &listsinceblock, false, false },
|
||||||
{ "dumpprivkey", &dumpprivkey, false },
|
{ "dumpprivkey", &dumpprivkey, false, false },
|
||||||
{ "importprivkey", &importprivkey, false },
|
{ "importprivkey", &importprivkey, false, false },
|
||||||
{ "listunspent", &listunspent, false },
|
{ "listunspent", &listunspent, false, false },
|
||||||
{ "getrawtransaction", &getrawtransaction, false },
|
{ "getrawtransaction", &getrawtransaction, false, false },
|
||||||
{ "createrawtransaction", &createrawtransaction, false },
|
{ "createrawtransaction", &createrawtransaction, false, false },
|
||||||
{ "decoderawtransaction", &decoderawtransaction, false },
|
{ "decoderawtransaction", &decoderawtransaction, false, false },
|
||||||
{ "signrawtransaction", &signrawtransaction, false },
|
{ "signrawtransaction", &signrawtransaction, false, false },
|
||||||
{ "sendrawtransaction", &sendrawtransaction, false },
|
{ "sendrawtransaction", &sendrawtransaction, false, false },
|
||||||
};
|
};
|
||||||
|
|
||||||
CRPCTable::CRPCTable()
|
CRPCTable::CRPCTable()
|
||||||
@ -1008,9 +1008,13 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
|
|||||||
// Execute
|
// Execute
|
||||||
Value result;
|
Value result;
|
||||||
{
|
{
|
||||||
|
if (pcmd->unlocked)
|
||||||
|
result = pcmd->actor(params, false);
|
||||||
|
else {
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
result = pcmd->actor(params, false);
|
result = pcmd->actor(params, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
std::string name;
|
std::string name;
|
||||||
rpcfn_type actor;
|
rpcfn_type actor;
|
||||||
bool okSafeMode;
|
bool okSafeMode;
|
||||||
|
bool unlocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user