LCOV - code coverage report
Current view: top level - src/zmq - zmqabstractnotifier.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 13 14 92.9 %
Date: 2020-09-26 01:30:44 Functions: 11 11 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2015-2018 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 <zmq/zmqconfig.h>
       9             : 
      10             : class CBlockIndex;
      11             : class CZMQAbstractNotifier;
      12             : 
      13             : typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)();
      14             : 
      15             : class CZMQAbstractNotifier
      16             : {
      17             : public:
      18             :     static const int DEFAULT_ZMQ_SNDHWM {1000};
      19             : 
      20           8 :     CZMQAbstractNotifier() : psocket(nullptr), outbound_message_high_water_mark(DEFAULT_ZMQ_SNDHWM) { }
      21             :     virtual ~CZMQAbstractNotifier();
      22             : 
      23             :     template <typename T>
      24           8 :     static CZMQAbstractNotifier* Create()
      25             :     {
      26           8 :         return new T();
      27           0 :     }
      28             : 
      29          19 :     std::string GetType() const { return type; }
      30           8 :     void SetType(const std::string &t) { type = t; }
      31          19 :     std::string GetAddress() const { return address; }
      32           8 :     void SetAddress(const std::string &a) { address = a; }
      33           4 :     int GetOutboundMessageHighWaterMark() const { return outbound_message_high_water_mark; }
      34           8 :     void SetOutboundMessageHighWaterMark(const int sndhwm) {
      35           8 :         if (sndhwm >= 0) {
      36           8 :             outbound_message_high_water_mark = sndhwm;
      37           8 :         }
      38           8 :     }
      39             : 
      40             :     virtual bool Initialize(void *pcontext) = 0;
      41             :     virtual void Shutdown() = 0;
      42             : 
      43             :     virtual bool NotifyBlock(const CBlockIndex *pindex);
      44             :     virtual bool NotifyTransaction(const CTransaction &transaction);
      45             : 
      46             : protected:
      47             :     void *psocket;
      48             :     std::string type;
      49             :     std::string address;
      50             :     int outbound_message_high_water_mark; // aka SNDHWM
      51             : };
      52             : 
      53             : #endif // BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H

Generated by: LCOV version 1.15