6 个版本
0.2.0-alpha.1 | 2019 年 11 月 9 日 |
---|---|
0.2.0-alpha.0 | 2019 年 11 月 4 日 |
0.1.3 | 2019 年 9 月 11 日 |
0.1.2 | 2019 年 8 月 17 日 |
#16 in #zmq
每月 23 次下载
12KB
96 行
Rust Bitcoin ZMQ
这个crate提供对Bitcoin ZMQ的相对简单的封装,允许构建交易或区块数据的异步流。
需求
sudo apt install pkg-config libzmq3-dev
使用方法
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");
}
依赖项
~3.5MB
~73K SLoC