6 releases
0.2.0-alpha.1 | Nov 9, 2019 |
---|---|
0.2.0-alpha.0 | Nov 4, 2019 |
0.1.3 | Sep 11, 2019 |
0.1.2 | Aug 17, 2019 |
#17 in #zmq
12KB
96 lines
Rust Bitcoin ZMQ
This crate provides a relatively thin wrapper around Bitcoin ZMQ, allowing for the construction of asynchronous streams of transaction or block data.
Requirements
sudo apt install pkg-config libzmq3-dev
Usage
use bitcoin_zmq::ZMQListener;
use futures::prelude::*;
#[tokio::main]
async fn main() {
// Construct ZMQ listenr
let listener = ZMQListener::bind("tcp://127.0.0.1:28332")
.await
.expect("could not connect");
// Do something with stream of messages
listener
.stream()
.take(10)
.try_for_each(move |raw| {
println!("raw message: {:?}", hex::encode(raw));
future::ok(())
})
.await
.expect("zmq error'd during stream");
}
Dependencies
~3.5MB
~74K SLoC