Skip to content

Commit caac39b

Browse files
committed
Make ZMQ notification interface instance global.
This moves the used instance of CZMQNotificationInterface from a static variable in init.cpp to a globally-accessible one declared in zmq/zmqnotificationinterface.h. The variable is also renamed to g_zmq_notification_interface, to be consistent with other globals. We need this to implement a new RPC method "getzmqnotifications" (see bitcoin/bitcoin#13526) in a follow up.
1 parent 2643fa5 commit caac39b

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/init.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ void DummyWalletInit::AddWalletOptions() const
9999
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
100100
#endif
101101

102-
#if ENABLE_ZMQ
103-
static CZMQNotificationInterface* pzmqNotificationInterface = nullptr;
104-
#endif
105-
106102
#ifdef WIN32
107103
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
108104
// accessing block files don't count towards the fd_set size limit
@@ -279,10 +275,10 @@ void Shutdown()
279275
g_wallet_init_interface.Stop();
280276

281277
#if ENABLE_ZMQ
282-
if (pzmqNotificationInterface) {
283-
UnregisterValidationInterface(pzmqNotificationInterface);
284-
delete pzmqNotificationInterface;
285-
pzmqNotificationInterface = nullptr;
278+
if (g_zmq_notification_interface) {
279+
UnregisterValidationInterface(g_zmq_notification_interface);
280+
delete g_zmq_notification_interface;
281+
g_zmq_notification_interface = nullptr;
286282
}
287283
#endif
288284

@@ -1409,10 +1405,10 @@ bool AppInitMain()
14091405
}
14101406

14111407
#if ENABLE_ZMQ
1412-
pzmqNotificationInterface = CZMQNotificationInterface::Create();
1408+
g_zmq_notification_interface = CZMQNotificationInterface::Create();
14131409

1414-
if (pzmqNotificationInterface) {
1415-
RegisterValidationInterface(pzmqNotificationInterface);
1410+
if (g_zmq_notification_interface) {
1411+
RegisterValidationInterface(g_zmq_notification_interface);
14161412
}
14171413
#endif
14181414
uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set

src/zmq/zmqnotificationinterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,5 @@ void CZMQNotificationInterface::BlockDisconnected(const std::shared_ptr<const CB
180180
TransactionAddedToMempool(ptx);
181181
}
182182
}
183+
184+
CZMQNotificationInterface* g_zmq_notification_interface = nullptr;

src/zmq/zmqnotificationinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ class CZMQNotificationInterface final : public CValidationInterface
3737
std::list<CZMQAbstractNotifier*> notifiers;
3838
};
3939

40+
extern CZMQNotificationInterface* g_zmq_notification_interface;
41+
4042
#endif // BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H

0 commit comments

Comments
 (0)