33
33
namespace libbitcoin {
34
34
namespace protocol {
35
35
namespace zmq {
36
-
36
+
37
37
static const auto subscribe_all = " " ;
38
38
static constexpr int32_t zmq_true = 1 ;
39
39
static constexpr int32_t zmq_false = 0 ;
@@ -42,7 +42,7 @@ static constexpr int32_t reconnect_interval = 100;
42
42
static const bc::protocol::settings default_settings;
43
43
44
44
// Linger
45
- // The default value of -1 specifies an infinite linger period. Pending
45
+ // The default value of -1 specifies an infinite linger period. Pending
46
46
// messages shall not be discarded after a call to zmq_close(); attempting to
47
47
// terminate the socket's context with zmq_term() shall block until all pending
48
48
// messages have been sent to a peer. The value 0 specifies no linger period.
@@ -241,6 +241,13 @@ bool socket::set(int32_t option, const std::string& value)
241
241
return zmq_setsockopt (self_, option, buffer, value.size ()) != zmq_fail;
242
242
}
243
243
244
+ // private
245
+ bool socket::set (int32_t option, const data_chunk& value)
246
+ {
247
+ return zmq_setsockopt (self_, option, value.data (), value.size ())
248
+ != zmq_fail;
249
+ }
250
+
244
251
// For NULL security, ZAP calls are only made for non-empty domain.
245
252
// For PLAIN/CURVE, calls are always made if ZAP handler is present.
246
253
bool socket::set_authentication_domain (const std::string& domain)
@@ -288,6 +295,16 @@ bool socket::set_socks_proxy(const config::authority& socks_proxy)
288
295
return socks_proxy && set (ZMQ_SOCKS_PROXY, socks_proxy.to_string ());
289
296
}
290
297
298
+ bool socket::set_subscription (const data_chunk& filter)
299
+ {
300
+ return set (ZMQ_SUBSCRIBE, filter);
301
+ }
302
+
303
+ bool socket::set_unsubscription (const data_chunk& filter)
304
+ {
305
+ return set (ZMQ_UNSUBSCRIBE, filter);
306
+ }
307
+
291
308
code socket::send (message& packet)
292
309
{
293
310
return packet.send (*this );
0 commit comments