Bitcoin ABC  0.24.7
P2P Digital Currency
zmqabstractnotifier.h
Go to the documentation of this file.
1 // Copyright (c) 2015 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 <memory>
9 #include <string>
10 
11 class CBlockIndex;
12 class CTransaction;
14 
15 using CZMQNotifierFactory = std::unique_ptr<CZMQAbstractNotifier> (*)();
16 
18 public:
19  static const int DEFAULT_ZMQ_SNDHWM{1000};
20 
22  : psocket(nullptr),
24  virtual ~CZMQAbstractNotifier();
25 
26  template <typename T>
27  static std::unique_ptr<CZMQAbstractNotifier> Create() {
28  return std::make_unique<T>();
29  }
30 
31  std::string GetType() const { return type; }
32  void SetType(const std::string &t) { type = t; }
33  std::string GetAddress() const { return address; }
34  void SetAddress(const std::string &a) { address = a; }
37  }
38  void SetOutboundMessageHighWaterMark(const int sndhwm) {
39  if (sndhwm >= 0) {
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,
55  uint64_t mempool_sequence);
56  // Notifies of every mempool removal, except inclusion in blocks
57  virtual bool NotifyTransactionRemoval(const CTransaction &transaction,
58  uint64_t mempool_sequence);
59  // Notifies of transactions added to mempool or appearing in blocks
60  virtual bool NotifyTransaction(const CTransaction &transaction);
61 
62 protected:
63  void *psocket;
64  std::string type;
65  std::string address;
67 };
68 
69 #endif // BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
CZMQAbstractNotifier::NotifyBlockDisconnect
virtual bool NotifyBlockDisconnect(const CBlockIndex *pindex)
Definition: zmqabstractnotifier.cpp:29
CZMQAbstractNotifier::type
std::string type
Definition: zmqabstractnotifier.h:64
CZMQAbstractNotifier::DEFAULT_ZMQ_SNDHWM
static const int DEFAULT_ZMQ_SNDHWM
Definition: zmqabstractnotifier.h:19
CZMQAbstractNotifier::NotifyTransactionAcceptance
virtual bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence)
Definition: zmqabstractnotifier.cpp:34
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:194
CZMQAbstractNotifier
Definition: zmqabstractnotifier.h:17
CZMQAbstractNotifier::Shutdown
virtual void Shutdown()=0
CZMQAbstractNotifier::psocket
void * psocket
Definition: zmqabstractnotifier.h:63
CZMQAbstractNotifier::SetOutboundMessageHighWaterMark
void SetOutboundMessageHighWaterMark(const int sndhwm)
Definition: zmqabstractnotifier.h:38
CZMQAbstractNotifier::SetAddress
void SetAddress(const std::string &a)
Definition: zmqabstractnotifier.h:34
CZMQNotifierFactory
std::unique_ptr< CZMQAbstractNotifier >(*)() CZMQNotifierFactory
Definition: zmqabstractnotifier.h:15
CZMQAbstractNotifier::outbound_message_high_water_mark
int outbound_message_high_water_mark
Definition: zmqabstractnotifier.h:66
CZMQAbstractNotifier::SetType
void SetType(const std::string &t)
Definition: zmqabstractnotifier.h:32
CZMQAbstractNotifier::GetType
std::string GetType() const
Definition: zmqabstractnotifier.h:31
CZMQAbstractNotifier::~CZMQAbstractNotifier
virtual ~CZMQAbstractNotifier()
Definition: zmqabstractnotifier.cpp:11
CZMQAbstractNotifier::Initialize
virtual bool Initialize(void *pcontext)=0
CZMQAbstractNotifier::address
std::string address
Definition: zmqabstractnotifier.h:65
CZMQAbstractNotifier::NotifyTransactionRemoval
virtual bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence)
Definition: zmqabstractnotifier.cpp:39
CZMQAbstractNotifier::Create
static std::unique_ptr< CZMQAbstractNotifier > Create()
Definition: zmqabstractnotifier.h:27
CZMQAbstractNotifier::NotifyTransaction
virtual bool NotifyTransaction(const CTransaction &transaction)
Definition: zmqabstractnotifier.cpp:19
CZMQAbstractNotifier::GetAddress
std::string GetAddress() const
Definition: zmqabstractnotifier.h:33
CZMQAbstractNotifier::CZMQAbstractNotifier
CZMQAbstractNotifier()
Definition: zmqabstractnotifier.h:21
CZMQAbstractNotifier::NotifyBlockConnect
virtual bool NotifyBlockConnect(const CBlockIndex *pindex)
Definition: zmqabstractnotifier.cpp:24
CZMQAbstractNotifier::NotifyBlock
virtual bool NotifyBlock(const CBlockIndex *pindex)
Definition: zmqabstractnotifier.cpp:15
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:23
CZMQAbstractNotifier::GetOutboundMessageHighWaterMark
int GetOutboundMessageHighWaterMark() const
Definition: zmqabstractnotifier.h:35