rpc: Add getrpcinfo command #14982

pull promag wants to merge 5 commits into bitcoin:master from promag:2018-12-getrpcinfo changing 3 files +73 −4
  1. promag commented at 1:57 pm on December 17, 2018: member

    The new getrpcinfo command exposes details of the RPC interface. The details can be configuration properties or runtime values/stats.

    This can be particular useful to coordinate concurrent functional tests (see #14958 from where this was extracted).

  2. rpc: Remove unused PreCommand signal bf4383277d
  3. fanquake added the label RPC/REST/ZMQ on Dec 17, 2018
  4. in src/rpc/server.cpp:34 in 9d4d3ab95f outdated
    30@@ -31,12 +31,12 @@ static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server starte
    31 static RPCTimerInterface* timerInterface = nullptr;
    32 /* Map of name to timer. */
    33 static std::map<std::string, std::unique_ptr<RPCTimerBase> > deadlineTimers;
    34+static std::shared_ptr<int> g_active_commands_counter = std::make_shared<int>(0);
    


    promag commented at 1:59 pm on December 17, 2018:
    This is temporary, just for concept ACK.

    jonasschnelli commented at 5:48 am on December 19, 2018:
    Yeah. I suggest using a manual increment rather then the use_count()
  5. in src/rpc/server.cpp:270 in 9d4d3ab95f outdated
    265+        );
    266+    }
    267+
    268+    UniValue result(UniValue::VOBJ);
    269+    result.pushKV("active_commands", (uint64_t) g_active_commands_counter.use_count() - 1);
    270+    result.pushKV("uptime", GetTime() - GetStartupTime());
    


    promag commented at 1:59 pm on December 17, 2018:
    This is an example.
  6. laanwj commented at 2:27 pm on December 17, 2018: member
    Concept ACK
  7. in src/rpc/server.cpp:279 in 9d4d3ab95f outdated
    274 // clang-format off
    275 static const CRPCCommand vRPCCommands[] =
    276 { //  category              name                      actor (function)         argNames
    277   //  --------------------- ------------------------  -----------------------  ----------
    278     /* Overall control/query calls */
    279+    { "control",            "getrpcinfo",          &getrpcinfo,          {}  },
    


    Empact commented at 7:43 am on December 18, 2018:
    nit: whitespace
  8. in src/rpc/server.cpp:269 in 9d4d3ab95f outdated
    264+                .ToString()
    265+        );
    266+    }
    267+
    268+    UniValue result(UniValue::VOBJ);
    269+    result.pushKV("active_commands", (uint64_t) g_active_commands_counter.use_count() - 1);
    


    Empact commented at 7:44 am on December 18, 2018:
    "active_command_count"?
  9. in src/rpc/server.cpp:262 in 9d4d3ab95f outdated
    254@@ -255,11 +255,28 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
    255     return GetTime() - GetStartupTime();
    256 }
    257 
    258+static UniValue getrpcinfo(const JSONRPCRequest& request)
    259+{
    260+    if (request.fHelp || request.params.size() > 0) {
    261+        throw std::runtime_error(
    262+            RPCHelpMan{"getrpcino",
    


    practicalswift commented at 3:53 pm on December 18, 2018:
    Should be “getrpcinfo”? :-)

    instagibbs commented at 3:07 pm on December 21, 2018:
    “getalpcino”

    MarcoFalke commented at 3:24 pm on December 21, 2018:
    __func__

    promag commented at 3:32 pm on December 21, 2018:
  10. in src/rpc/server.cpp:506 in 9d4d3ab95f outdated
    500@@ -484,10 +501,9 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
    501     if (!pcmd)
    502         throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
    503 
    504-    g_rpcSignals.PreCommand(*pcmd);
    505-
    506     try
    507     {
    508+        auto active_command = g_active_commands_counter;
    


    practicalswift commented at 3:53 pm on December 18, 2018:
    active_command unused? :-)

    promag commented at 3:57 pm on December 18, 2018:
    Ya, the idea is to have a RAII counter and for now I’m using the shared ptr usage counter 😅
  11. promag commented at 3:56 pm on December 18, 2018: member
    @Empact @practicalswift I guess you concept ACK?
  12. ch4ot1c commented at 10:56 pm on December 18, 2018: contributor

    Concept Ack.

    Does uptime belong in the response? Should it be a separate rpc_uptime, measured instead from StartRPC / the Started signal?: https://github.com/bitcoin/bitcoin/blob/24b3b788be9bdf24019c5e46a7943db7c4328389/src/init.cpp#L733

  13. jonasschnelli commented at 5:50 am on December 19, 2018: contributor

    Concept ACK.

    • What about showing active commands (things like rescanblockchain and scantxoutset)?
  14. practicalswift commented at 7:10 am on December 21, 2018: contributor
    Concept ACK
  15. instagibbs commented at 3:10 pm on December 21, 2018: member
    concept ACK . could it add things like port it’s listening to?
  16. promag commented at 3:21 pm on December 21, 2018: member
    I guess you have to know that to call this RPC?
  17. instagibbs commented at 3:23 pm on December 21, 2018: member
    @promag the computer knows this, yes ;P
  18. laanwj commented at 10:17 am on January 2, 2019: member
    So I’d say if everyone is Concept ACK, I think it makes sense to fix the nits, utACK and merge this and add further ideas in later PRs.
  19. rpc: Track active commands 068a8fc05f
  20. rpc: Add getrpcinfo command d0730f5ce4
  21. qa: Add tests for getrpcinfo 251a91c1bf
  22. doc: Add getrpcinfo release notes a0ac15459a
  23. promag force-pushed on Jan 2, 2019
  24. promag commented at 2:42 pm on January 2, 2019: member
    @laanwj updated.
  25. laanwj commented at 11:57 pm on January 9, 2019: member
    utACK a0ac15459a0df598e1ee1fd36a3899a129cecaeb
  26. jonasschnelli commented at 7:24 pm on January 13, 2019: contributor

    tested ACK 251a91c1bf245b3674c2612149382a0f1e18dc98

    It currently mildly useful and I can’t follow the discussion why uptime is gone. But this is a great starting point for a general RPC state report.

  27. laanwj merged this on Jan 14, 2019
  28. laanwj closed this on Jan 14, 2019

  29. laanwj referenced this in commit cf0c67b62c on Jan 14, 2019
  30. promag deleted the branch on Jan 14, 2019
  31. pravblockc referenced this in commit 4f3dbaad66 on Aug 10, 2021
  32. pravblockc referenced this in commit af3419c931 on Aug 10, 2021
  33. pravblockc referenced this in commit 724eecb675 on Aug 14, 2021
  34. kittywhiskers referenced this in commit fd42242f28 on Oct 31, 2021
  35. kittywhiskers referenced this in commit 046ca7709d on Nov 1, 2021
  36. kittywhiskers referenced this in commit 25bbae46f7 on Nov 4, 2021
  37. kittywhiskers referenced this in commit 8646801fb0 on Nov 4, 2021
  38. kittywhiskers referenced this in commit f4a1fceae7 on Nov 6, 2021
  39. kittywhiskers referenced this in commit b1e193bb1e on Nov 14, 2021
  40. kittywhiskers referenced this in commit 7203f5d25e on Nov 14, 2021
  41. kittywhiskers referenced this in commit d5c209884c on Nov 14, 2021
  42. kittywhiskers referenced this in commit 71b90dad97 on Nov 14, 2021
  43. pravblockc referenced this in commit 574017d86e on Nov 18, 2021
  44. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-23 00:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me