Bitcoin Core 30.99.0
P2P Digital Currency
zmqnotificationinterface.h
Go to the documentation of this file.
1// Copyright (c) 2015-present 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
10
11#include <cstddef>
12#include <cstdint>
13#include <functional>
14#include <list>
15#include <memory>
16#include <vector>
17
18class CBlockIndex;
20
22{
23public:
25
26 std::list<const CZMQAbstractNotifier*> GetActiveNotifiers() const;
27
28 static std::unique_ptr<CZMQNotificationInterface> Create(std::function<bool(std::vector<std::byte>&, const CBlockIndex&)> get_block_by_index);
29
30protected:
31 bool Initialize();
32 void Shutdown();
33
34 // CValidationInterface
35 void TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t mempool_sequence) override;
36 void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override;
37 void BlockConnected(const kernel::ChainstateRole& role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
38 void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected) override;
39 void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
40
41private:
43
44 void* pcontext{nullptr};
45 std::list<std::unique_ptr<CZMQAbstractNotifier>> notifiers;
46};
47
48extern std::unique_ptr<CZMQNotificationInterface> g_zmq_notification_interface;
49
50#endif // BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:95
Implement this to subscribe to events generated in validation and mempool.
static std::unique_ptr< CZMQNotificationInterface > Create(std::function< bool(std::vector< std::byte > &, const CBlockIndex &)> get_block_by_index)
void TransactionAddedToMempool(const NewMempoolTransactionInfo &tx, uint64_t mempool_sequence) override
Notifies listeners of a transaction having been added to mempool.
void BlockConnected(const kernel::ChainstateRole &role, const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexConnected) override
Notifies listeners of a block being connected.
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 Provides the block that was 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
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:403
Information about chainstate that notifications are sent from.
Definition: types.h:18
std::unique_ptr< CZMQNotificationInterface > g_zmq_notification_interface