Bitcoin Core  26.99.0
P2P Digital Currency
zmqpublishnotifier.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_ZMQPUBLISHNOTIFIER_H
6 #define BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H
7 
9 
10 #include <cstddef>
11 #include <cstdint>
12 #include <functional>
13 
14 class CBlock;
15 class CBlockIndex;
16 class CTransaction;
17 
19 {
20 private:
21  uint32_t nSequence {0U};
22 
23 public:
24 
25  /* send zmq multipart message
26  parts:
27  * command
28  * data
29  * message sequence number
30  */
31  bool SendZmqMessage(const char *command, const void* data, size_t size);
32 
33  bool Initialize(void *pcontext) override;
34  void Shutdown() override;
35 };
36 
38 {
39 public:
40  bool NotifyBlock(const CBlockIndex *pindex) override;
41 };
42 
44 {
45 public:
46  bool NotifyTransaction(const CTransaction &transaction) override;
47 };
48 
50 {
51 private:
52  const std::function<bool(CBlock&, const CBlockIndex&)> m_get_block_by_index;
53 
54 public:
55  CZMQPublishRawBlockNotifier(std::function<bool(CBlock&, const CBlockIndex&)> get_block_by_index)
56  : m_get_block_by_index{std::move(get_block_by_index)} {}
57  bool NotifyBlock(const CBlockIndex *pindex) override;
58 };
59 
61 {
62 public:
63  bool NotifyTransaction(const CTransaction &transaction) override;
64 };
65 
67 {
68 public:
69  bool NotifyBlockConnect(const CBlockIndex *pindex) override;
70  bool NotifyBlockDisconnect(const CBlockIndex *pindex) override;
71  bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence) override;
72  bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence) override;
73 };
74 
75 #endif // BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H
const auto command
Definition: block.h:69
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:150
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:296
bool SendZmqMessage(const char *command, const void *data, size_t size)
uint32_t nSequence
upcounting per message sequence number
bool Initialize(void *pcontext) override
bool NotifyBlock(const CBlockIndex *pindex) override
bool NotifyTransaction(const CTransaction &transaction) override
const std::function< bool(CBlock &, const CBlockIndex &)> m_get_block_by_index
bool NotifyBlock(const CBlockIndex *pindex) override
CZMQPublishRawBlockNotifier(std::function< bool(CBlock &, const CBlockIndex &)> get_block_by_index)
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence) override
bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence) override
bool NotifyBlockConnect(const CBlockIndex *pindex) override
bool NotifyBlockDisconnect(const CBlockIndex *pindex) override