11 #include <validation.h>
25 std::list<const CZMQAbstractNotifier*> result;
27 result.push_back(n.get());
34 std::map<std::string, CZMQNotifierFactory> factories;
35 factories[
"pubhashblock"] = CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>;
36 factories[
"pubhashtx"] = CZMQAbstractNotifier::Create<CZMQPublishHashTransactionNotifier>;
37 factories[
"pubrawblock"] = CZMQAbstractNotifier::Create<CZMQPublishRawBlockNotifier>;
38 factories[
"pubrawtx"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionNotifier>;
39 factories[
"pubsequence"] = CZMQAbstractNotifier::Create<CZMQPublishSequenceNotifier>;
41 std::list<std::unique_ptr<CZMQAbstractNotifier>>
notifiers;
42 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);
58 notificationInterface->notifiers = std::move(
notifiers);
60 if (notificationInterface->Initialize()) {
61 return notificationInterface.release();
71 int major = 0, minor = 0, patch = 0;
72 zmq_version(&major, &minor, &patch);
82 zmqError(
"Unable to initialize context");
87 if (notifier->Initialize(
pcontext)) {
88 LogPrint(
BCLog::ZMQ,
"zmq: Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress());
90 LogPrint(
BCLog::ZMQ,
"zmq: Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress());
105 LogPrint(
BCLog::ZMQ,
"zmq: Shutdown notifier %s at %s\n", notifier->GetType(), notifier->GetAddress());
106 notifier->Shutdown();
116 template <
typename Function>
117 void TryForEachAndRemoveFailed(std::list<std::unique_ptr<CZMQAbstractNotifier>>& notifiers,
const Function& func)
119 for (
auto i = notifiers.begin(); i != notifiers.end(); ) {
121 if (func(notifier)) {
125 i = notifiers.erase(i);
134 if (fInitialDownload || pindexNew == pindexFork)