MCPcopy Create free account
hub / github.com/ElementsProject/elements / Create

Method Create

src/zmq/zmqnotificationinterface.cpp:32–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32CZMQNotificationInterface* 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)
69bool CZMQNotificationInterface::Initialize()

Callers

nothing calls this directly

Calls 9

GetArgsMethod · 0.80
SetAddressMethod · 0.80
GetIntArgMethod · 0.80
releaseMethod · 0.80
SetTypeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
InitializeMethod · 0.45

Tested by

no test coverage detected