Changeset View
Changeset View
Standalone View
Standalone View
src/zmq/zmqnotificationinterface.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | CZMQNotificationInterface *CZMQNotificationInterface::Create() { | ||||
for (const auto &entry : factories) { | for (const auto &entry : factories) { | ||||
std::string arg("-zmq" + entry.first); | std::string arg("-zmq" + entry.first); | ||||
if (gArgs.IsArgSet(arg)) { | if (gArgs.IsArgSet(arg)) { | ||||
CZMQNotifierFactory factory = entry.second; | CZMQNotifierFactory factory = entry.second; | ||||
std::string address = gArgs.GetArg(arg, ""); | std::string address = gArgs.GetArg(arg, ""); | ||||
CZMQAbstractNotifier *notifier = factory(); | CZMQAbstractNotifier *notifier = factory(); | ||||
notifier->SetType(entry.first); | notifier->SetType(entry.first); | ||||
notifier->SetAddress(address); | notifier->SetAddress(address); | ||||
notifier->SetOutboundMessageHighWaterMark( | |||||
static_cast<int>(gArgs.GetArg( | |||||
arg + "hwm", CZMQAbstractNotifier::DEFAULT_ZMQ_SNDHWM))); | |||||
notifiers.push_back(notifier); | notifiers.push_back(notifier); | ||||
} | } | ||||
} | } | ||||
if (!notifiers.empty()) { | if (!notifiers.empty()) { | ||||
notificationInterface = new CZMQNotificationInterface(); | notificationInterface = new CZMQNotificationInterface(); | ||||
notificationInterface->notifiers = notifiers; | notificationInterface->notifiers = notifiers; | ||||
Show All 21 Lines | if (!pcontext) { | ||||
zmqError("Unable to initialize context"); | zmqError("Unable to initialize context"); | ||||
return false; | return false; | ||||
} | } | ||||
std::list<CZMQAbstractNotifier *>::iterator i = notifiers.begin(); | std::list<CZMQAbstractNotifier *>::iterator i = notifiers.begin(); | ||||
for (; i != notifiers.end(); ++i) { | for (; i != notifiers.end(); ++i) { | ||||
CZMQAbstractNotifier *notifier = *i; | CZMQAbstractNotifier *notifier = *i; | ||||
if (notifier->Initialize(pcontext)) { | if (notifier->Initialize(pcontext)) { | ||||
LogPrint(BCLog::ZMQ, " Notifier %s ready (address = %s)\n", | LogPrint(BCLog::ZMQ, "zmq: Notifier %s ready (address = %s)\n", | ||||
notifier->GetType(), notifier->GetAddress()); | notifier->GetType(), notifier->GetAddress()); | ||||
} else { | } else { | ||||
LogPrint(BCLog::ZMQ, " Notifier %s failed (address = %s)\n", | LogPrint(BCLog::ZMQ, "zmq: Notifier %s failed (address = %s)\n", | ||||
notifier->GetType(), notifier->GetAddress()); | notifier->GetType(), notifier->GetAddress()); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (i != notifiers.end()) { | if (i != notifiers.end()) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
// Called during shutdown sequence | // Called during shutdown sequence | ||||
void CZMQNotificationInterface::Shutdown() { | void CZMQNotificationInterface::Shutdown() { | ||||
LogPrint(BCLog::ZMQ, "zmq: Shutdown notification interface\n"); | LogPrint(BCLog::ZMQ, "zmq: Shutdown notification interface\n"); | ||||
if (pcontext) { | if (pcontext) { | ||||
for (std::list<CZMQAbstractNotifier *>::iterator i = notifiers.begin(); | for (std::list<CZMQAbstractNotifier *>::iterator i = notifiers.begin(); | ||||
i != notifiers.end(); ++i) { | i != notifiers.end(); ++i) { | ||||
CZMQAbstractNotifier *notifier = *i; | CZMQAbstractNotifier *notifier = *i; | ||||
LogPrint(BCLog::ZMQ, " Shutdown notifier %s at %s\n", | LogPrint(BCLog::ZMQ, "zmq: Shutdown notifier %s at %s\n", | ||||
notifier->GetType(), notifier->GetAddress()); | notifier->GetType(), notifier->GetAddress()); | ||||
notifier->Shutdown(); | notifier->Shutdown(); | ||||
} | } | ||||
zmq_ctx_term(pcontext); | zmq_ctx_term(pcontext); | ||||
pcontext = nullptr; | pcontext = nullptr; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |