Bitcoin Core  24.99.0
P2P Digital Currency
zmqnotificationinterface.h
Go to the documentation of this file.
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_ZMQNOTIFICATIONINTERFACE_H
6 #define BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
7 
9 #include <validationinterface.h>
10 
11 #include <cstdint>
12 #include <list>
13 #include <memory>
14 
15 class CBlock;
16 class CBlockIndex;
18 
20 {
21 public:
23 
24  std::list<const CZMQAbstractNotifier*> GetActiveNotifiers() const;
25 
27 
28 protected:
29  bool Initialize();
30  void Shutdown();
31 
32  // CValidationInterface
33  void TransactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override;
34  void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override;
35  void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
36  void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected) override;
37  void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
38 
39 private:
41 
42  void* pcontext{nullptr};
43  std::list<std::unique_ptr<CZMQAbstractNotifier>> notifiers;
44 };
45 
47 
48 #endif // BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
Definition: block.h:69
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:151
Implement this to subscribe to events generated in validation.
void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexConnected) override
Notifies listeners of a block being connected.
static CZMQNotificationInterface * Create()
void TransactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
Notifies listeners of a transaction having been added to mempool.
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Notifies listeners when the block chain tip advances.
std::list< std::unique_ptr< CZMQAbstractNotifier > > notifiers
void BlockDisconnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexDisconnected) override
Notifies listeners of a block being disconnected.
void TransactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
Notifies listeners of a transaction leaving mempool.
std::list< const CZMQAbstractNotifier * > GetActiveNotifiers() const
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:421
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:231
CZMQNotificationInterface * g_zmq_notification_interface