9 #include <validation.h> 15 LogPrint(
BCLog::ZMQ,
"zmq: Error: %s, errno=%s\n", str, zmq_strerror(errno));
26 for (std::list<CZMQAbstractNotifier*>::iterator i=
notifiers.begin(); i!=
notifiers.end(); ++i)
34 std::list<const CZMQAbstractNotifier*> result;
44 std::map<std::string, CZMQNotifierFactory> factories;
45 std::list<CZMQAbstractNotifier*>
notifiers;
47 factories[
"pubhashblock"] = CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>;
48 factories[
"pubhashtx"] = CZMQAbstractNotifier::Create<CZMQPublishHashTransactionNotifier>;
49 factories[
"pubrawblock"] = CZMQAbstractNotifier::Create<CZMQPublishRawBlockNotifier>;
50 factories[
"pubrawtx"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionNotifier>;
52 for (
const auto& entry : factories)
54 std::string arg(
"-zmq" + entry.first);
73 delete notificationInterface;
74 notificationInterface =
nullptr;
78 return notificationInterface;
84 int major = 0, minor = 0, patch = 0;
85 zmq_version(&major, &minor, &patch);
86 LogPrint(
BCLog::ZMQ,
"zmq: version %d.%d.%d\n", major, minor, patch);
88 LogPrint(
BCLog::ZMQ,
"zmq: Initialize notification interface\n");
95 zmqError(
"Unable to initialize context");
99 std::list<CZMQAbstractNotifier*>::iterator i=
notifiers.begin();
125 LogPrint(
BCLog::ZMQ,
"zmq: Shutdown notification interface\n");
128 for (std::list<CZMQAbstractNotifier*>::iterator i=
notifiers.begin(); i!=
notifiers.end(); ++i)
142 if (fInitialDownload || pindexNew == pindexFork)
145 for (std::list<CZMQAbstractNotifier*>::iterator i =
notifiers.begin(); i!=
notifiers.end(); )
166 for (std::list<CZMQAbstractNotifier*>::iterator i =
notifiers.begin(); i!=
notifiers.end(); )
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
void TransactionAddedToMempool(const CTransactionRef &tx) override
Notifies listeners of a transaction having been added to mempool.
virtual bool NotifyBlock(const CBlockIndex *pindex)
std::string GetAddress() const
void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexConnected, const std::vector< CTransactionRef > &vtxConflicted) override
Notifies listeners of a block being connected.
std::shared_ptr< const CTransaction > CTransactionRef
static CZMQNotificationInterface * Create()
virtual bool NotifyTransaction(const CTransaction &transaction)
virtual ~CZMQNotificationInterface()
void BlockDisconnected(const std::shared_ptr< const CBlock > &pblock) override
Notifies listeners of a block being disconnected.
void SetAddress(const std::string &a)
virtual void Shutdown()=0
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Notifies listeners when the block chain tip advances.
std::list< CZMQAbstractNotifier * > notifiers
void zmqError(const char *str)
The block chain is a tree shaped structure starting with the genesis block at the root...
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
CZMQAbstractNotifier *(* CZMQNotifierFactory)()
virtual bool Initialize(void *pcontext)=0
std::list< const CZMQAbstractNotifier * > GetActiveNotifiers() const
The basic transaction that is broadcasted on the network and contained in blocks. ...
CZMQNotificationInterface()
void SetType(const std::string &t)
std::string GetType() const
CZMQNotificationInterface * g_zmq_notification_interface