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