NAME

Net::Async::Blockchain::Client::ZMQ - Async ZMQ Client.

SYNOPSIS

my $loop = IO::Async::Loop->new();

$loop->add(my $zmq_source = Ryu::Async->new);

$loop->add(
    my $zmq_client = Net::Async::Blockchain::Client::ZMQ->new(
        endpoint => 'tpc://127.0.0.1:28332',
    ));

$zmq_client->subscribe('hashblock')->each(sub{print shift->{hash}})->get;

DESCRIPTION

client for the bitcoin ZMQ server

source

Create an Ryu::Source instance, if it is already defined just return the object

Ryu::Source

endpoint

TCP ZMQ endpoint

URL containing the port if needed, in case of DNS this will be resolved to an IP.

timeout

Timeout time for connection

Integer time in seconds

msg_timeout

Timeout time for received messages, this is applied when we have a bigger duration interval between the messages.

Integer time in seconds

socket_client

ZMQ socket

return the socket for ZMQ ZMQ::LibZMQ3

configure

Any additional configuration that is not described on IO::Async::Notifier must be included and removed here.

If this class receive a DNS as endpoint this will be resolved on this method to an IP address.

  • endpoint

  • timeout connection timeout (seconds)

  • msg_timeout msg interval timetout (seconds)

subscribe

Connect to the ZMQ server and start the subscription

  • subscription subscription string name

Ryu::Source

_recv_multipart

Since each response is partial we need to join them

  • subscription subscription string name

Multipart response array

shutdown

run the configured shutdown action if any

  • error error message

INHERITED METHODS

IO::Async::Notifier

add_child, adopt_future, adopted_futures, can_event, children, configure_unknown, debug_printf, get_loop, invoke_error, invoke_event, loop, make_event_cb, maybe_invoke_event, maybe_make_event_cb, new, notifier_name, parent, remove_child, remove_from_parent