Changeset View
Changeset View
Standalone View
Standalone View
src/zmq/zmqnotificationinterface.cpp
// Copyright (c) 2015-2016 The Bitcoin Core developers | // Copyright (c) 2015-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <zmq/zmqnotificationinterface.h> | #include <zmq/zmqnotificationinterface.h> | ||||
#include <zmq/zmqpublishnotifier.h> | #include <zmq/zmqpublishnotifier.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
Show All 11 Lines | CZMQNotificationInterface::~CZMQNotificationInterface() { | ||||
Shutdown(); | Shutdown(); | ||||
for (std::list<CZMQAbstractNotifier *>::iterator i = notifiers.begin(); | for (std::list<CZMQAbstractNotifier *>::iterator i = notifiers.begin(); | ||||
i != notifiers.end(); ++i) { | i != notifiers.end(); ++i) { | ||||
delete *i; | delete *i; | ||||
} | } | ||||
} | } | ||||
std::list<const CZMQAbstractNotifier *> | |||||
CZMQNotificationInterface::GetActiveNotifiers() const { | |||||
std::list<const CZMQAbstractNotifier *> result; | |||||
for (const auto *n : notifiers) { | |||||
result.push_back(n); | |||||
} | |||||
return result; | |||||
} | |||||
CZMQNotificationInterface *CZMQNotificationInterface::Create() { | CZMQNotificationInterface *CZMQNotificationInterface::Create() { | ||||
CZMQNotificationInterface *notificationInterface = nullptr; | CZMQNotificationInterface *notificationInterface = nullptr; | ||||
std::map<std::string, CZMQNotifierFactory> factories; | std::map<std::string, CZMQNotifierFactory> factories; | ||||
std::list<CZMQAbstractNotifier *> notifiers; | std::list<CZMQAbstractNotifier *> notifiers; | ||||
factories["pubhashblock"] = | factories["pubhashblock"] = | ||||
CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>; | CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>; | ||||
factories["pubhashtx"] = | factories["pubhashtx"] = | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
void CZMQNotificationInterface::BlockDisconnected( | void CZMQNotificationInterface::BlockDisconnected( | ||||
const std::shared_ptr<const CBlock> &pblock) { | const std::shared_ptr<const CBlock> &pblock) { | ||||
for (const CTransactionRef &ptx : pblock->vtx) { | for (const CTransactionRef &ptx : pblock->vtx) { | ||||
// Do a normal notify for each transaction removed in block | // Do a normal notify for each transaction removed in block | ||||
// disconnection | // disconnection | ||||
TransactionAddedToMempool(ptx); | TransactionAddedToMempool(ptx); | ||||
} | } | ||||
} | } | ||||
CZMQNotificationInterface *g_zmq_notification_interface = nullptr; |