11
11
#include < util/strencodings.h>
12
12
#include < util/string.h>
13
13
#include < util/system.h>
14
+ #include < util/time.h>
14
15
15
16
#include < boost/signals2/signal.hpp>
16
17
17
18
#include < cassert>
18
- #include < memory> // for unique_ptr
19
+ #include < chrono>
20
+ #include < memory>
19
21
#include < mutex>
20
22
#include < unordered_map>
21
23
24
+ using SteadyClock = std::chrono::steady_clock;
25
+
22
26
static GlobalMutex g_rpc_warmup_mutex;
23
27
static std::atomic<bool > g_rpc_running{false };
24
28
static bool fRPCInWarmup GUARDED_BY (g_rpc_warmup_mutex) = true;
@@ -33,7 +37,7 @@ static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& req
33
37
struct RPCCommandExecutionInfo
34
38
{
35
39
std::string method;
36
- int64_t start;
40
+ SteadyClock::time_point start;
37
41
};
38
42
39
43
struct RPCServerInfo
@@ -50,7 +54,7 @@ struct RPCCommandExecution
50
54
explicit RPCCommandExecution (const std::string& method)
51
55
{
52
56
LOCK (g_rpc_server_info.mutex );
53
- it = g_rpc_server_info.active_commands .insert (g_rpc_server_info.active_commands .end (), {method, GetTimeMicros ()});
57
+ it = g_rpc_server_info.active_commands .insert (g_rpc_server_info.active_commands .end (), {method, SteadyClock::now ()});
54
58
}
55
59
~RPCCommandExecution ()
56
60
{
@@ -231,7 +235,7 @@ static RPCHelpMan getrpcinfo()
231
235
for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands ) {
232
236
UniValue entry (UniValue::VOBJ);
233
237
entry.pushKV (" method" , info.method );
234
- entry.pushKV (" duration" , GetTimeMicros ( ) - info.start );
238
+ entry.pushKV (" duration" , int64_t {Ticks<std::chrono::microseconds>( SteadyClock::now ( ) - info.start )} );
235
239
active_commands.push_back (entry);
236
240
}
237
241
0 commit comments