LCOV - code coverage report
Current view: top level - src/zmq - zmqrpc.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 97.0 % 33 32
Test Date: 2025-08-25 05:11:47 Functions: 100.0 % 3 3
Branches: 52.0 % 98 51

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2018-2022 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <zmq/zmqrpc.h>
       6                 :             : 
       7                 :             : #include <rpc/server.h>
       8                 :             : #include <rpc/util.h>
       9                 :             : #include <zmq/zmqabstractnotifier.h>
      10                 :             : #include <zmq/zmqnotificationinterface.h>
      11                 :             : 
      12                 :             : #include <univalue.h>
      13                 :             : 
      14                 :             : #include <list>
      15                 :             : #include <string>
      16                 :             : 
      17                 :             : class JSONRPCRequest;
      18                 :             : 
      19                 :             : namespace {
      20                 :             : 
      21                 :        2608 : static RPCHelpMan getzmqnotifications()
      22                 :             : {
      23                 :        2608 :     return RPCHelpMan{
      24                 :        2608 :         "getzmqnotifications",
      25         [ +  - ]:        5216 :         "Returns information about the active ZeroMQ notifications.\n",
      26                 :             :                 {},
      27         [ +  - ]:        5216 :                 RPCResult{
      28         [ +  - ]:        5216 :                     RPCResult::Type::ARR, "", "",
      29                 :             :                     {
      30   [ +  -  +  - ]:        5216 :                         {RPCResult::Type::OBJ, "", "",
      31                 :             :                         {
      32   [ +  -  +  - ]:        5216 :                             {RPCResult::Type::STR, "type", "Type of notification"},
      33   [ +  -  +  - ]:        5216 :                             {RPCResult::Type::STR, "address", "Address of the publisher"},
      34   [ +  -  +  - ]:        5216 :                             {RPCResult::Type::NUM, "hwm", "Outbound message high water mark"},
      35                 :             :                         }},
      36                 :             :                     }
      37   [ +  -  +  -  :       23472 :                 },
          +  -  +  +  +  
             +  -  -  -  
                      - ]
      38                 :        2608 :                 RPCExamples{
      39   [ +  -  +  -  :        5216 :                     HelpExampleCli("getzmqnotifications", "")
                   +  - ]
      40   [ +  -  +  -  :       10432 :             + HelpExampleRpc("getzmqnotifications", "")
             +  -  +  - ]
      41         [ +  - ]:        2608 :                 },
      42                 :        2608 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
      43                 :             : {
      44                 :           4 :     UniValue result(UniValue::VARR);
      45         [ +  + ]:           4 :     if (g_zmq_notification_interface != nullptr) {
      46   [ +  -  +  + ]:          10 :         for (const auto* n : g_zmq_notification_interface->GetActiveNotifiers()) {
      47                 :           8 :             UniValue obj(UniValue::VOBJ);
      48   [ -  +  +  -  :          24 :             obj.pushKV("type", n->GetType());
             +  -  +  - ]
      49   [ -  +  +  -  :          24 :             obj.pushKV("address", n->GetAddress());
             +  -  +  - ]
      50   [ +  -  +  -  :          16 :             obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
                   +  - ]
      51         [ +  - ]:           8 :             result.push_back(std::move(obj));
      52                 :          10 :         }
      53                 :             :     }
      54                 :             : 
      55                 :           4 :     return result;
      56                 :           0 : },
      57   [ +  -  +  - ]:       10432 :     };
      58   [ +  -  +  -  :       10432 : }
          +  -  +  -  -  
                      - ]
      59                 :             : 
      60                 :             : const CRPCCommand commands[]{
      61                 :             :     {"zmq", &getzmqnotifications},
      62                 :             : };
      63                 :             : 
      64                 :             : } // anonymous namespace
      65                 :             : 
      66                 :        1094 : void RegisterZMQRPCCommands(CRPCTable& t)
      67                 :             : {
      68         [ +  + ]:        2188 :     for (const auto& c : commands) {
      69                 :        1094 :         t.appendCommand(c.name, &c);
      70                 :             :     }
      71                 :        1094 : }
        

Generated by: LCOV version 2.0-1