Skip to content

Commit

Permalink
Add genesis-chunked CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 committed Jun 27, 2024
1 parent 52fbc03 commit d23bc9b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rpc/src/client/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ enum ClientRequest {
ConsensusState,
/// Get the node's genesis data.
Genesis,
/// Get the node's genesis data by chunks
GenesisChunked,
/// Get the node's health.
Health,
/// Request the latest block.
Expand Down Expand Up @@ -413,6 +415,20 @@ where
serde_json::to_string_pretty(&client.genesis::<serde_json::Value>().await?)
.map_err(Error::serde)?
},
ClientRequest::GenesisChunked => {
let mut data = Vec::new();
let mut chunks = client.genesis_chunked_stream().await;

while let Some(chunk) = chunks.next().await {
let mut chunk = chunk?;
data.append(&mut chunk);
}

let genesis: tendermint::genesis::Genesis<serde_json::Value> =
serde_json::from_slice(&data).map_err(Error::serde)?;

serde_json::to_string_pretty(&genesis).map_err(Error::serde)?
},
ClientRequest::Health => {
serde_json::to_string_pretty(&client.health().await?).map_err(Error::serde)?
},
Expand Down

0 comments on commit d23bc9b

Please sign in to comment.