LCOV - code coverage report
Current view: top level - src/zmq - zmqabstractnotifier.h (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 0.0 % 11 0
Test Date: 2024-08-28 04:44:32 Functions: 0.0 % 4 0
Branches: 0.0 % 26 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2015-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                 :             : #ifndef BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
       6                 :             : #define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
       7                 :             : 
       8                 :             : #include <cstdint>
       9                 :             : #include <functional>
      10                 :             : #include <memory>
      11                 :             : #include <string>
      12                 :             : 
      13                 :             : class CBlockIndex;
      14                 :             : class CTransaction;
      15                 :             : class CZMQAbstractNotifier;
      16                 :             : 
      17                 :             : using CZMQNotifierFactory = std::function<std::unique_ptr<CZMQAbstractNotifier>()>;
      18                 :             : 
      19                 :             : class CZMQAbstractNotifier
      20                 :             : {
      21                 :             : public:
      22                 :             :     static const int DEFAULT_ZMQ_SNDHWM {1000};
      23                 :             : 
      24                 :           0 :     CZMQAbstractNotifier() : outbound_message_high_water_mark(DEFAULT_ZMQ_SNDHWM) {}
      25                 :             :     virtual ~CZMQAbstractNotifier();
      26                 :             : 
      27                 :             :     template <typename T>
      28                 :           0 :     static std::unique_ptr<CZMQAbstractNotifier> Create()
      29                 :             :     {
      30                 :           0 :         return std::make_unique<T>();
      31                 :             :     }
      32                 :             : 
      33   [ #  #  #  #  :           0 :     std::string GetType() const { return type; }
           #  # ][ #  #  
             #  #  #  # ]
      34   [ #  #  #  # ]:           0 :     void SetType(const std::string &t) { type = t; }
      35         [ #  # ]:           0 :     std::string GetAddress() const { return address; }
      36   [ #  #  #  # ]:           0 :     void SetAddress(const std::string &a) { address = a; }
      37         [ #  # ]:           0 :     int GetOutboundMessageHighWaterMark() const { return outbound_message_high_water_mark; }
      38                 :           0 :     void SetOutboundMessageHighWaterMark(const int sndhwm) {
      39         [ #  # ]:           0 :         if (sndhwm >= 0) {
      40                 :           0 :             outbound_message_high_water_mark = sndhwm;
      41                 :             :         }
      42                 :             :     }
      43                 :             : 
      44                 :             :     virtual bool Initialize(void *pcontext) = 0;
      45                 :             :     virtual void Shutdown() = 0;
      46                 :             : 
      47                 :             :     // Notifies of ConnectTip result, i.e., new active tip only
      48                 :             :     virtual bool NotifyBlock(const CBlockIndex *pindex);
      49                 :             :     // Notifies of every block connection
      50                 :             :     virtual bool NotifyBlockConnect(const CBlockIndex *pindex);
      51                 :             :     // Notifies of every block disconnection
      52                 :             :     virtual bool NotifyBlockDisconnect(const CBlockIndex *pindex);
      53                 :             :     // Notifies of every mempool acceptance
      54                 :             :     virtual bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence);
      55                 :             :     // Notifies of every mempool removal, except inclusion in blocks
      56                 :             :     virtual bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence);
      57                 :             :     // Notifies of transactions added to mempool or appearing in blocks
      58                 :             :     virtual bool NotifyTransaction(const CTransaction &transaction);
      59                 :             : 
      60                 :             : protected:
      61                 :             :     void* psocket{nullptr};
      62                 :             :     std::string type;
      63                 :             :     std::string address;
      64                 :             :     int outbound_message_high_water_mark; // aka SNDHWM
      65                 :             : };
      66                 :             : 
      67                 :             : #endif // BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
        

Generated by: LCOV version 2.0-1