1 个不稳定版本
0.1.0 | 2023 年 9 月 11 日 |
---|
#456 在 HTTP 客户端
37KB
710 行
🎲 🦀 drand-client-rs
一个简单的 Rust 编写的 drand 客户端实现
功能
- HTTP 传输
pedersen-bls-chained
方案pedersen-bls-unchained
方案bls-unchained-on-g1
方案bls-unchained-on-g1-rfc9380
方案
示例用法
use drand_client_rs::{new_http_client, DrandClientError};
fn main() -> Result<(), DrandClientError> {
// first create the client using one of the relays as a `base_url`
let drand_client = new_http_client("https://api.drand.sh")?;
// you can fetch the latest random value using `latest_randomness`
if let Ok(beacon) = drand_client.latest_randomness() {
println!("the latest round is {}", beacon.round_number);
println!("the latest randomness is {:?}", beacon.randomness);
}
// or a specific round using `randomness`
if let Ok(beacon) = drand_client.randomness(1) {
println!("the selected round is {}", beacon.round_number);
println!("the latest randomness is {:?}", beacon.randomness);
}
Ok(())
}
路线图
- rustdoc
- 特定的 wasm 目标
- libp2p 传输
依赖项
~5–16MB
~249K SLoC