Changeset View
Changeset View
Standalone View
Standalone View
src/zmq/zmqnotificationinterface.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if (!notifiers.empty()) { | ||||
} | } | ||||
} | } | ||||
return notificationInterface; | return notificationInterface; | ||||
} | } | ||||
// Called at startup to conditionally set up ZMQ socket(s) | // Called at startup to conditionally set up ZMQ socket(s) | ||||
bool CZMQNotificationInterface::Initialize() { | bool CZMQNotificationInterface::Initialize() { | ||||
int major = 0, minor = 0, patch = 0; | |||||
zmq_version(&major, &minor, &patch); | |||||
LogPrint(BCLog::ZMQ, "zmq: version %d.%d.%d\n", major, minor, patch); | |||||
LogPrint(BCLog::ZMQ, "zmq: Initialize notification interface\n"); | LogPrint(BCLog::ZMQ, "zmq: Initialize notification interface\n"); | ||||
assert(!pcontext); | assert(!pcontext); | ||||
pcontext = zmq_init(1); | pcontext = zmq_ctx_new(); | ||||
if (!pcontext) { | 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) { | ||||
Show All 21 Lines | void CZMQNotificationInterface::Shutdown() { | ||||
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, " Shutdown notifier %s at %s\n", | ||||
notifier->GetType(), notifier->GetAddress()); | notifier->GetType(), notifier->GetAddress()); | ||||
notifier->Shutdown(); | notifier->Shutdown(); | ||||
} | } | ||||
zmq_ctx_destroy(pcontext); | zmq_ctx_term(pcontext); | ||||
pcontext = nullptr; | pcontext = nullptr; | ||||
} | } | ||||
} | } | ||||
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, | void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, | ||||
const CBlockIndex *pindexFork, | const CBlockIndex *pindexFork, | ||||
bool fInitialDownload) { | bool fInitialDownload) { | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |