20 std::list<const CZMQAbstractNotifier *>
22 std::list<const CZMQAbstractNotifier *> result;
24 result.push_back(n.get());
30 std::map<std::string, CZMQNotifierFactory> factories;
31 factories[
"pubhashblock"] =
32 CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>;
33 factories[
"pubhashtx"] =
34 CZMQAbstractNotifier::Create<CZMQPublishHashTransactionNotifier>;
35 factories[
"pubrawblock"] =
36 CZMQAbstractNotifier::Create<CZMQPublishRawBlockNotifier>;
37 factories[
"pubrawtx"] =
38 CZMQAbstractNotifier::Create<CZMQPublishRawTransactionNotifier>;
39 factories[
"pubsequence"] =
40 CZMQAbstractNotifier::Create<CZMQPublishSequenceNotifier>;
42 std::list<std::unique_ptr<CZMQAbstractNotifier>>
notifiers;
43 for (
const auto &entry : factories) {
44 std::string arg(
"-zmq" + entry.first);
45 const auto &factory = entry.second;
47 std::unique_ptr<CZMQAbstractNotifier> notifier = factory();
48 notifier->SetType(entry.first);
49 notifier->SetAddress(address);
50 notifier->SetOutboundMessageHighWaterMark(
58 std::unique_ptr<CZMQNotificationInterface> notificationInterface(
60 notificationInterface->notifiers = std::move(
notifiers);
62 if (notificationInterface->Initialize()) {
63 return notificationInterface.release();
72 int major = 0, minor = 0, patch = 0;
73 zmq_version(&major, &minor, &patch);
82 zmqError(
"Unable to initialize context");
87 if (notifier->Initialize(
pcontext)) {
89 notifier->GetType(), notifier->GetAddress());
92 notifier->GetType(), notifier->GetAddress());
106 notifier->GetType(), notifier->GetAddress());
107 notifier->Shutdown();
117 template <
typename Function>
118 void TryForEachAndRemoveFailed(
119 std::list<std::unique_ptr<CZMQAbstractNotifier>> ¬ifiers,
120 const Function &func) {
121 for (
auto i = notifiers.begin(); i != notifiers.end();) {
123 if (func(notifier)) {
127 i = notifiers.erase(i);
136 bool fInitialDownload) {
138 if (fInitialDownload || pindexNew == pindexFork) {
150 uint64_t mempool_sequence) {
153 TryForEachAndRemoveFailed(
162 uint64_t mempool_sequence) {
166 TryForEachAndRemoveFailed(
173 const std::shared_ptr<const CBlock> &pblock,
184 TryForEachAndRemoveFailed(
191 const std::shared_ptr<const CBlock> &pblock,
202 TryForEachAndRemoveFailed(
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
The block chain is a tree shaped structure starting with the genesis block at the root,...
The basic transaction that is broadcasted on the network and contained in blocks.
virtual void Shutdown()=0
virtual bool NotifyBlockConnect(const CBlockIndex *pindex)
static const int DEFAULT_ZMQ_SNDHWM
virtual bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence)
virtual bool NotifyBlock(const CBlockIndex *pindex)
virtual bool NotifyTransaction(const CTransaction &transaction)
virtual bool NotifyBlockDisconnect(const CBlockIndex *pindex)
virtual bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence)
void TransactionAddedToMempool(const CTransactionRef &tx, std::shared_ptr< const std::vector< Coin >>, uint64_t mempool_sequence) override
Notifies listeners of a transaction having been added to mempool.
virtual ~CZMQNotificationInterface()
void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexConnected) override
Notifies listeners of a block being connected.
static CZMQNotificationInterface * Create()
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.
CZMQNotificationInterface()
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
#define LogPrint(category,...)
std::shared_ptr< const CTransaction > CTransactionRef
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
CZMQNotificationInterface * g_zmq_notification_interface
void zmqError(const char *str)