1 // Copyright (c) 2015-2019 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 
8 #include <validationinterface.h>
9 #include <list>
10 
11 class CBlockIndex;
12 class CZMQAbstractNotifier;
13 
14 class CZMQNotificationInterface final : public CValidationInterface
15 {
16 public:
17     virtual ~CZMQNotificationInterface();
18 
19     std::list<const CZMQAbstractNotifier*> GetActiveNotifiers() const;
20 
21     static CZMQNotificationInterface* Create();
22 
23 protected:
24     bool Initialize();
25     void Shutdown();
26 
27     // CValidationInterface
28     void TransactionAddedToMempool(const CTransactionRef& tx) override;
29     void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
30     void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected) override;
31     void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
32 
33 private:
34     CZMQNotificationInterface();
35 
36     void *pcontext;
37     std::list<CZMQAbstractNotifier*> notifiers;
38 };
39 
40 extern CZMQNotificationInterface* g_zmq_notification_interface;
41 
42 #endif // BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
43