LCOV - code coverage report
Current view: top level - src/zmq - zmqrpc.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 34.6 % 26 9
Test Date: 2024-08-28 04:44:32 Functions: 33.3 % 3 1
Branches: 34.3 % 108 37

             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                 :         256 : static RPCHelpMan getzmqnotifications()
      22                 :             : {
      23                 :         256 :     return RPCHelpMan{"getzmqnotifications",
      24                 :             :                 "\nReturns information about the active ZeroMQ notifications.\n",
      25                 :             :                 {},
      26                 :           0 :                 RPCResult{
      27                 :             :                     RPCResult::Type::ARR, "", "",
      28                 :             :                     {
      29                 :             :                         {RPCResult::Type::OBJ, "", "",
      30                 :             :                         {
      31                 :             :                             {RPCResult::Type::STR, "type", "Type of notification"},
      32                 :             :                             {RPCResult::Type::STR, "address", "Address of the publisher"},
      33                 :             :                             {RPCResult::Type::NUM, "hwm", "Outbound message high water mark"},
      34                 :             :                         }},
      35                 :             :                     }
      36   [ +  -  +  -  :        1792 :                 },
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  +  
          +  +  -  -  -  
                      - ]
      37                 :         256 :                 RPCExamples{
      38   [ +  -  +  -  :         512 :                     HelpExampleCli("getzmqnotifications", "")
                   +  - ]
      39   [ +  -  +  -  :        1024 :             + HelpExampleRpc("getzmqnotifications", "")
             +  -  +  - ]
      40         [ +  - ]:         256 :                 },
      41                 :           0 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
      42                 :             : {
      43                 :           0 :     UniValue result(UniValue::VARR);
      44         [ #  # ]:           0 :     if (g_zmq_notification_interface != nullptr) {
      45   [ #  #  #  # ]:           0 :         for (const auto* n : g_zmq_notification_interface->GetActiveNotifiers()) {
      46                 :           0 :             UniValue obj(UniValue::VOBJ);
      47   [ #  #  #  #  :           0 :             obj.pushKV("type", n->GetType());
             #  #  #  # ]
      48   [ #  #  #  #  :           0 :             obj.pushKV("address", n->GetAddress());
             #  #  #  # ]
      49   [ #  #  #  #  :           0 :             obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
                   #  # ]
      50         [ #  # ]:           0 :             result.push_back(std::move(obj));
      51                 :           0 :         }
      52                 :             :     }
      53                 :             : 
      54                 :           0 :     return result;
      55                 :           0 : },
      56   [ +  -  +  -  :        1536 :     };
             +  -  +  - ]
      57   [ +  -  +  -  :        1280 : }
          +  -  +  -  +  
                -  -  - ]
      58                 :             : 
      59                 :             : const CRPCCommand commands[]{
      60                 :             :     {"zmq", &getzmqnotifications},
      61                 :             : };
      62                 :             : 
      63                 :             : } // anonymous namespace
      64                 :             : 
      65                 :           0 : void RegisterZMQRPCCommands(CRPCTable& t)
      66                 :             : {
      67         [ #  # ]:           0 :     for (const auto& c : commands) {
      68                 :           0 :         t.appendCommand(c.name, &c);
      69                 :             :     }
      70                 :           0 : }
        

Generated by: LCOV version 2.0-1