| 30 | } |
| 31 | |
| 32 | CZMQNotificationInterface* CZMQNotificationInterface::Create() |
| 33 | { |
| 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>; |
| 40 | |
| 41 | std::list<std::unique_ptr<CZMQAbstractNotifier>> notifiers; |
| 42 | for (const auto& entry : factories) |
| 43 | { |
| 44 | std::string arg("-zmq" + entry.first); |
| 45 | const auto& factory = entry.second; |
| 46 | for (const std::string& address : gArgs.GetArgs(arg)) { |
| 47 | std::unique_ptr<CZMQAbstractNotifier> notifier = factory(); |
| 48 | notifier->SetType(entry.first); |
| 49 | notifier->SetAddress(address); |
| 50 | notifier->SetOutboundMessageHighWaterMark(static_cast<int>(gArgs.GetIntArg(arg + "hwm", CZMQAbstractNotifier::DEFAULT_ZMQ_SNDHWM))); |
| 51 | notifiers.push_back(std::move(notifier)); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | if (!notifiers.empty()) |
| 56 | { |
| 57 | std::unique_ptr<CZMQNotificationInterface> notificationInterface(new CZMQNotificationInterface()); |
| 58 | notificationInterface->notifiers = std::move(notifiers); |
| 59 | |
| 60 | if (notificationInterface->Initialize()) { |
| 61 | return notificationInterface.release(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return nullptr; |
| 66 | } |
| 67 | |
| 68 | // Called at startup to conditionally set up ZMQ socket(s) |
| 69 | bool CZMQNotificationInterface::Initialize() |
nothing calls this directly
no test coverage detected