-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpc: Add
/genesis_chunked
query (#1439)
* Add /genesis_chunked query * Add changelog entry * Fix comments * Update types of GenesisChunked request and response * Convert chunk and total fields from GenesisChunked response * Improve genesis_chunked_stream method * Add genesis-chunked CLI * Fix dependencies for genesis_chunked_stream * Update changelog entry --------- Co-authored-by: Romain Ruetschi <romain@informal.systems>
- Loading branch information
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/features/1438-genesis-chunked-endpoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- `[tendermint-rpc]` Add support for the `/genesis_chunked` RPC endpoint | ||
([\#1438](https://github.com/informalsystems/tendermint-rs/issues/1438)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! `/genesis_chunked` endpoint JSON-RPC wrapper | ||
|
||
use alloc::{ | ||
string::{String, ToString}, | ||
vec::Vec, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use tendermint_proto::serializers; | ||
|
||
use crate::{dialect::Dialect, request::RequestMessage}; | ||
|
||
/// Get the genesis state in multiple chunks for the current chain | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
pub struct Request { | ||
pub chunk: String, | ||
} | ||
|
||
impl Request { | ||
pub fn new(chunk: u64) -> Self { | ||
Self { | ||
chunk: chunk.to_string(), | ||
} | ||
} | ||
} | ||
|
||
impl RequestMessage for Request { | ||
fn method(&self) -> crate::Method { | ||
crate::Method::GenesisChunked | ||
} | ||
} | ||
|
||
impl<S> crate::Request<S> for Request | ||
where | ||
S: Dialect, | ||
{ | ||
type Response = Response; | ||
} | ||
|
||
impl<S> crate::SimpleRequest<S> for Request | ||
where | ||
S: Dialect, | ||
{ | ||
type Output = Response; | ||
} | ||
|
||
/// Block responses | ||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Response { | ||
#[serde(with = "serializers::from_str")] | ||
pub chunk: u64, | ||
#[serde(with = "serializers::from_str")] | ||
pub total: u64, | ||
#[serde(with = "serializers::bytes::base64string")] | ||
pub data: Vec<u8>, | ||
} | ||
|
||
impl crate::Response for Response {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters