From edfb4d98e782ae41bc8d0c9754caaa7e1a20c696 Mon Sep 17 00:00:00 2001 From: mruddy <6440430+mruddy@users.noreply.github.com> Date: Sat, 30 Jun 2018 10:32:33 -0400 Subject: [PATCH] [depends, zmq, doc] avoid deprecated zeromq api functions Zcash: Backported from bitcoin/bitcoin#13578 --- doc/zmq.md | 7 ++++--- src/zmq/zmqnotificationinterface.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/zmq.md b/doc/zmq.md index f75566dc4..e7e5469bf 100644 --- a/doc/zmq.md +++ b/doc/zmq.md @@ -33,9 +33,10 @@ buffering or reassembly. ## Prerequisites -The ZeroMQ feature in Zcash requires ZeroMQ API version 4.x or -newer, which you will need to install if you are not using the depends -system. Typically, it is packaged by distributions as something like +The ZeroMQ feature in Zcash requires the ZeroMQ API >= 4.0.0 +[libzmq](https://github.com/zeromq/libzmq/releases), which you will +need to install if you are not using the depends system. +Typically, it is packaged by distributions as something like *libzmq5-dev*. The C++ wrapper for ZeroMQ is *not* needed. In order to run the example Python client scripts in contrib/ one must diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index 22c3b3901..fa56291c9 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -73,10 +73,14 @@ CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const // Called at startup to conditionally set up ZMQ socket(s) bool CZMQNotificationInterface::Initialize() { + int major = 0, minor = 0, patch = 0; + zmq_version(&major, &minor, &patch); + LogPrint("zmq", "zmq: version %d.%d.%d\n", major, minor, patch); + LogPrint("zmq", "zmq: Initialize notification interface\n"); assert(!pcontext); - pcontext = zmq_init(1); + pcontext = zmq_ctx_new(); if (!pcontext) { @@ -119,7 +123,7 @@ void CZMQNotificationInterface::Shutdown() LogPrint("zmq", " Shutdown notifier %s at %s\n", notifier->GetType(), notifier->GetAddress()); notifier->Shutdown(); } - zmq_ctx_destroy(pcontext); + zmq_ctx_term(pcontext); pcontext = 0; }