mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-14 02:41:34 +02:00
rpc: Track active commands
This commit is contained in:
parent
bf4383277d
commit
068a8fc05f
@ -32,6 +32,35 @@ static RPCTimerInterface* timerInterface = nullptr;
|
|||||||
/* Map of name to timer. */
|
/* Map of name to timer. */
|
||||||
static std::map<std::string, std::unique_ptr<RPCTimerBase> > deadlineTimers;
|
static std::map<std::string, std::unique_ptr<RPCTimerBase> > deadlineTimers;
|
||||||
|
|
||||||
|
struct RPCCommandExecutionInfo
|
||||||
|
{
|
||||||
|
std::string method;
|
||||||
|
int64_t start;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RPCServerInfo
|
||||||
|
{
|
||||||
|
Mutex mutex;
|
||||||
|
std::list<RPCCommandExecutionInfo> active_commands GUARDED_BY(mutex);
|
||||||
|
};
|
||||||
|
|
||||||
|
static RPCServerInfo g_rpc_server_info;
|
||||||
|
|
||||||
|
struct RPCCommandExecution
|
||||||
|
{
|
||||||
|
std::list<RPCCommandExecutionInfo>::iterator it;
|
||||||
|
explicit RPCCommandExecution(const std::string& method)
|
||||||
|
{
|
||||||
|
LOCK(g_rpc_server_info.mutex);
|
||||||
|
it = g_rpc_server_info.active_commands.insert(g_rpc_server_info.active_commands.cend(), {method, GetTimeMicros()});
|
||||||
|
}
|
||||||
|
~RPCCommandExecution()
|
||||||
|
{
|
||||||
|
LOCK(g_rpc_server_info.mutex);
|
||||||
|
g_rpc_server_info.active_commands.erase(it);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static struct CRPCSignals
|
static struct CRPCSignals
|
||||||
{
|
{
|
||||||
boost::signals2::signal<void ()> Started;
|
boost::signals2::signal<void ()> Started;
|
||||||
@ -485,6 +514,7 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
RPCCommandExecution execution(request.strMethod);
|
||||||
// Execute, convert arguments to array if necessary
|
// Execute, convert arguments to array if necessary
|
||||||
if (request.params.isObject()) {
|
if (request.params.isObject()) {
|
||||||
return pcmd->actor(transformNamedArguments(request, pcmd->argNames));
|
return pcmd->actor(transformNamedArguments(request, pcmd->argNames));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user