#zmq #stream #bitcoin #non-blocking

bitcoin-zmq

一个提供对 Bitcoin ZMQ 的相对简单封装的库,允许构建交易或区块数据的异步流

6 个版本

0.2.0-alpha.12019 年 11 月 9 日
0.2.0-alpha.02019 年 11 月 4 日
0.1.3 2019 年 9 月 11 日
0.1.2 2019 年 8 月 17 日

#16 in #zmq

每月 23 次下载

MITGPL-3.0 许可协议

12KB
96

Rust Bitcoin ZMQ

Build Status License Cargo Documentation

这个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