mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
zmq: Make g_zmq_notification_interface
a smart pointer
courtesy of 8ed4ff8e from bitcoin#27125
This commit is contained in:
parent
0a1ffd30b9
commit
b0b4e0fa7f
@ -360,9 +360,8 @@ void PrepareShutdown(NodeContext& node)
|
|||||||
|
|
||||||
#if ENABLE_ZMQ
|
#if ENABLE_ZMQ
|
||||||
if (g_zmq_notification_interface) {
|
if (g_zmq_notification_interface) {
|
||||||
UnregisterValidationInterface(g_zmq_notification_interface);
|
UnregisterValidationInterface(g_zmq_notification_interface.get());
|
||||||
delete g_zmq_notification_interface;
|
g_zmq_notification_interface.reset();
|
||||||
g_zmq_notification_interface = nullptr;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1737,7 +1736,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
g_zmq_notification_interface = CZMQNotificationInterface::Create();
|
g_zmq_notification_interface = CZMQNotificationInterface::Create();
|
||||||
|
|
||||||
if (g_zmq_notification_interface) {
|
if (g_zmq_notification_interface) {
|
||||||
RegisterValidationInterface(g_zmq_notification_interface);
|
RegisterValidationInterface(g_zmq_notification_interface.get());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ std::list<const CZMQAbstractNotifier*> CZMQNotificationInterface::GetActiveNotif
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CZMQNotificationInterface* CZMQNotificationInterface::Create()
|
std::unique_ptr<CZMQNotificationInterface> CZMQNotificationInterface::Create()
|
||||||
{
|
{
|
||||||
std::map<std::string, CZMQNotifierFactory> factories;
|
std::map<std::string, CZMQNotifierFactory> factories;
|
||||||
factories["pubhashblock"] = CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>;
|
factories["pubhashblock"] = CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>;
|
||||||
@ -71,7 +71,7 @@ CZMQNotificationInterface* CZMQNotificationInterface::Create()
|
|||||||
notificationInterface->notifiers = std::move(notifiers);
|
notificationInterface->notifiers = std::move(notifiers);
|
||||||
|
|
||||||
if (notificationInterface->Initialize()) {
|
if (notificationInterface->Initialize()) {
|
||||||
return notificationInterface.release();
|
return notificationInterface;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,4 +219,4 @@ void CZMQNotificationInterface::NotifyRecoveredSig(const std::shared_ptr<const l
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CZMQNotificationInterface* g_zmq_notification_interface = nullptr;
|
std::unique_ptr<CZMQNotificationInterface> g_zmq_notification_interface;
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
std::list<const CZMQAbstractNotifier*> GetActiveNotifiers() const;
|
std::list<const CZMQAbstractNotifier*> GetActiveNotifiers() const;
|
||||||
|
|
||||||
static CZMQNotificationInterface* Create();
|
static std::unique_ptr<CZMQNotificationInterface> Create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
@ -44,6 +44,6 @@ private:
|
|||||||
std::list<std::unique_ptr<CZMQAbstractNotifier>> notifiers;
|
std::list<std::unique_ptr<CZMQAbstractNotifier>> notifiers;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CZMQNotificationInterface* g_zmq_notification_interface;
|
extern std::unique_ptr<CZMQNotificationInterface> g_zmq_notification_interface;
|
||||||
|
|
||||||
#endif // BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
|
#endif // BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user