1 个不稳定版本

0.1.0 2023年5月9日

#2230 in #blockchain

MIT/Apache

28KB
563

Rhoast 客户端

此crate允许您通过节点的grpc和http模块使用类型安全的rust轻松与运行中的0.13.x版本节点通信。

// example of a grpc propose and getting a block via hash
use rhoast_client_v03::grpc::Grpc;
use rhoast_client_v03::proto::casper::BlocksQueryByHeight;

 let grpc=Grpc::new("endpoint");
 let propose = grpc.propose(true).await.unwrap();

//for grpc stream actions like visualize_dag_util_stream, show_main_chain_util_stream, show_blocks_util_stream,
// get_blocks_by_height_util_stream  pass in a function that takes in the returned value of the stream
// as well as how many stream events should be listned to, passing in None as the number of optional stream event
// would make the grpc listen forever

let block_query=BlocksQueryByHeight{
    start_block_number: 1,
    end_block_number: 40
}
fn write_stream_to_file(input: &BlockInfoResponse){
//write input to file
}
grpc.get_blocks_by_height_util_stream(block_query, write_stream_to_file, Some(40)).await.unwrap();

文档链接 这里

测试

  • 要运行测试,执行URL=http://server_url PORT=port_number cargo test如果没有提供URL环境变量,则所有测试都将跳过

依赖关系

~6–14MB
~150K SLoC