Bitcoin Core  24.99.0
P2P Digital Currency
zmqabstractnotifier.h
Go to the documentation of this file.
1 // Copyright (c) 2015-2021 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 
9 #include <memory>
10 #include <string>
11 
12 class CBlockIndex;
13 class CTransaction;
15 
16 using CZMQNotifierFactory = std::unique_ptr<CZMQAbstractNotifier> (*)();
17 
19 {
20 public:
21  static const int DEFAULT_ZMQ_SNDHWM {1000};
22 
24  virtual ~CZMQAbstractNotifier();
25 
26  template <typename T>
27  static std::unique_ptr<CZMQAbstractNotifier> Create()
28  {
29  return std::make_unique<T>();
30  }
31 
32  std::string GetType() const { return type; }
33  void SetType(const std::string &t) { type = t; }
34  std::string GetAddress() const { return address; }
35  void SetAddress(const std::string &a) { address = a; }
37  void SetOutboundMessageHighWaterMark(const int sndhwm) {
38  if (sndhwm >= 0) {
40  }
41  }
42 
43  virtual bool Initialize(void *pcontext) = 0;
44  virtual void Shutdown() = 0;
45 
46  // Notifies of ConnectTip result, i.e., new active tip only
47  virtual bool NotifyBlock(const CBlockIndex *pindex);
48  // Notifies of every block connection
49  virtual bool NotifyBlockConnect(const CBlockIndex *pindex);
50  // Notifies of every block disconnection
51  virtual bool NotifyBlockDisconnect(const CBlockIndex *pindex);
52  // Notifies of every mempool acceptance
53  virtual bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence);
54  // Notifies of every mempool removal, except inclusion in blocks
55  virtual bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence);
56  // Notifies of transactions added to mempool or appearing in blocks
57  virtual bool NotifyTransaction(const CTransaction &transaction);
58 
59 protected:
60  void *psocket;
61  std::string type;
62  std::string address;
64 };
65 
66 #endif // BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:152
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:288
std::string GetType() const
virtual void Shutdown()=0
virtual bool NotifyBlockConnect(const CBlockIndex *pindex)
static const int DEFAULT_ZMQ_SNDHWM
void SetOutboundMessageHighWaterMark(const int sndhwm)
void SetAddress(const std::string &a)
virtual bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence)
virtual bool NotifyBlock(const CBlockIndex *pindex)
virtual bool Initialize(void *pcontext)=0
virtual bool NotifyTransaction(const CTransaction &transaction)
static std::unique_ptr< CZMQAbstractNotifier > Create()
std::string GetAddress() const
virtual bool NotifyBlockDisconnect(const CBlockIndex *pindex)
void SetType(const std::string &t)
int GetOutboundMessageHighWaterMark() const
virtual bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence)
std::unique_ptr< CZMQAbstractNotifier >(*)() CZMQNotifierFactory