8个版本
0.2.3 | 2019年7月2日 |
---|---|
0.2.2 | 2019年7月2日 |
0.1.3 | 2019年4月1日 |
0.1.2 | 2019年2月8日 |
0.1.1 | 2019年1月24日 |
21 in #rpc-api
每月45次下载
14KB
290 行
限流Bitcoin RPC客户端
这个crate最初是基于JeanDudey的Bitcoin RPC客户端的分支,但后来几乎完全重写。
这个crate实现了Rust中的Bitcoin RPC客户端,它不打算实现所有bitcoin rpc方法的完整实现,因此如果您需要某些方法,您可以为其创建一个pull request。
其他货币
使用相关的编译器标志,可与LTC和DOGE一起工作。
用法
将此添加到您的 Cargo.toml
[dependencies]
throttled_bitcoin_rpc = "0.1.0"
并添加到您的crate根目录
extern crate throttled_bitcoin_rpc;
示例:连接到bitcoin rpc服务器
extern crate throttled_bitcoin_rpc;
use throttled_bitcoin_rpc::BitcoinRpcClient;
fn main() {
let client = BitcoinRpcClient::new(
"example.org:8331",
Some("bitcoin".to_owned()),
Some("local321".to_owned()),
3, // max number of concurrent requests
10, // max number of requests per second
1000, // max size of batched requests
);
let block_count = match client.getblockcount().unwrap();
println!("Block count: {}", block_count);
let txs = vec![
"02617e68e8c3e3fa8763502c0e701bf5af1e8f57835b9bef1ee333b0fcf2527",
"969947e164bbfca77cb09eab343b192cb5605bfa0483b4d2a3ec626e55ad70bc",
"743f6202f89acc41adce4496244f152833ffb9f1f7a6d6e6fc94d85580ac9461",
];
use throttled_bitcoin_rpc::BatchRequest;
let mut batcher = client::batcher::<String>();
for txid in txs {
batcher.getrawtransaction(txid.to_owned(), false).unwrap();
}
println!("Raw TxData: {:?}", batcher.send().unwrap());
}
依赖项
~19MB
~423K SLoC