zmq::recv_multipart
This commit is contained in:
parent
494482eba5
commit
0bc7801da5
2 changed files with 5 additions and 12 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <zmq.hpp>
|
#include <zmq_addon.hpp>
|
||||||
|
|
||||||
#include <boost/signals2.hpp>
|
#include <boost/signals2.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -871,17 +871,9 @@ zmq_listener::zmq_listener(std::string _ip, uint32_t _zmq) :
|
||||||
std::vector<zmq::message_t> zmq_listener::receive_multipart() {
|
std::vector<zmq::message_t> zmq_listener::receive_multipart() {
|
||||||
std::vector<zmq::message_t> msgs;
|
std::vector<zmq::message_t> msgs;
|
||||||
|
|
||||||
int32_t more;
|
auto res = zmq::recv_multipart(socket, std::back_inserter(msgs));
|
||||||
size_t more_size = sizeof(more);
|
assert(res);
|
||||||
while (true) {
|
assert(3 == *res);
|
||||||
zmq::message_t msg;
|
|
||||||
socket.recv(&msg, 0);
|
|
||||||
socket.getsockopt(ZMQ_RCVMORE, &more, &more_size);
|
|
||||||
|
|
||||||
if (!more)
|
|
||||||
break;
|
|
||||||
msgs.push_back(std::move(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
@ -902,6 +894,7 @@ void zmq_listener::handle_zmq() {
|
||||||
const auto block_hash = boost::algorithm::hex(std::string(static_cast<char *>(msg[1].data()), msg[1].size()));
|
const auto block_hash = boost::algorithm::hex(std::string(static_cast<char *>(msg[1].data()), msg[1].size()));
|
||||||
event_received(block_hash);
|
event_received(block_hash);
|
||||||
} catch (zmq::error_t &e) {
|
} catch (zmq::error_t &e) {
|
||||||
|
elog("handle_zmq recv_multipart exception ${str}", ("str", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue