mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-22 06:05:48 +00:00
Stream blocks
This commit is contained in:
parent
42444e87ff
commit
76095661cb
@ -4,6 +4,7 @@ use hyper::client::connect::{Destination, HttpConnector};
|
|||||||
use tower_grpc::Request;
|
use tower_grpc::Request;
|
||||||
use tower_hyper::{client, util};
|
use tower_hyper::{client, util};
|
||||||
use tower_util::MakeService;
|
use tower_util::MakeService;
|
||||||
|
use futures::stream::Stream;
|
||||||
|
|
||||||
pub mod grpc_client {
|
pub mod grpc_client {
|
||||||
include!(concat!(env!("OUT_DIR"), "/cash.z.wallet.sdk.rpc.rs"));
|
include!(concat!(env!("OUT_DIR"), "/cash.z.wallet.sdk.rpc.rs"));
|
||||||
@ -29,19 +30,31 @@ pub fn main() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Wait until the client is ready...
|
// Wait until the client is ready...
|
||||||
CompactTxStreamer::new(conn).ready()
|
CompactTxStreamer::new(conn)
|
||||||
|
.ready()
|
||||||
|
.map_err(|e| eprintln!("streaming error {:?}", e))
|
||||||
})
|
})
|
||||||
.and_then(|mut client| {
|
.and_then(|mut client| {
|
||||||
use crate::grpc_client::ChainSpec;
|
use crate::grpc_client::BlockId;
|
||||||
|
use crate::grpc_client::BlockRange;
|
||||||
|
|
||||||
client.get_latest_block(Request::new(ChainSpec {}))
|
let bs = BlockId{ height: 588300, hash: vec!()};
|
||||||
|
let be = BlockId{ height: 588390, hash: vec!()};
|
||||||
|
|
||||||
|
let br = Request::new(BlockRange{ start: Some(bs), end: Some(be)});
|
||||||
|
client
|
||||||
|
.get_block_range(br)
|
||||||
|
.map_err(|e| {
|
||||||
|
eprintln!("RouteChat request failed; err={:?}", e);
|
||||||
})
|
})
|
||||||
.and_then(|response| {
|
.and_then(|response| {
|
||||||
println!("RESPONSE = {:?}", response);
|
let inbound = response.into_inner();
|
||||||
|
inbound.for_each(|b| {
|
||||||
|
println!("RESPONSE = {:?}", b);
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.map_err(|e| {
|
.map_err(|e| eprintln!("gRPC inbound stream error: {:?}", e))
|
||||||
println!("ERR = {:?}", e);
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
tokio::run(say_hello);
|
tokio::run(say_hello);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user