-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
block_search
RPC endpoint (#991)
* Add block_search RPC endpoint and tests * Add .changelog entry * Fix comments
- Loading branch information
Showing
11 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
- `[tendermint-rpc]` Add support for the `/block_search` RPC endpoint. See | ||
<https://docs.tendermint.com/master/rpc/\#/Info/block_search> for details | ||
([#832](https://github.com/informalsystems/tendermint-rs/issues/832)) |
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,48 @@ | ||
//! `/block_search` endpoint JSON-RPC wrapper | ||
|
||
pub use super::{block, block_results}; | ||
|
||
use crate::{Method, Order}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Request for searching for blocks by their BeginBlock and EndBlock events. | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
pub struct Request { | ||
pub query: String, | ||
#[serde(with = "tendermint_proto::serializers::from_str")] | ||
pub page: u32, | ||
#[serde(with = "tendermint_proto::serializers::from_str")] | ||
pub per_page: u8, | ||
pub order_by: Order, | ||
} | ||
|
||
impl Request { | ||
/// Constructor. | ||
pub fn new(query: impl ToString, page: u32, per_page: u8, order_by: Order) -> Self { | ||
Self { | ||
query: query.to_string(), | ||
page, | ||
per_page, | ||
order_by, | ||
} | ||
} | ||
} | ||
|
||
impl crate::Request for Request { | ||
type Response = Response; | ||
|
||
fn method(&self) -> Method { | ||
Method::BlockSearch | ||
} | ||
} | ||
|
||
impl crate::SimpleRequest for Request {} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Response { | ||
pub blocks: Vec<block::Response>, | ||
#[serde(with = "tendermint_proto::serializers::from_str")] | ||
pub total_count: u32, | ||
} | ||
|
||
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
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,70 @@ | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": "", | ||
"result": { | ||
"blocks": [ | ||
{ | ||
"block_id": { | ||
"hash": "4FFD15F274758E474898498A191EB8CA6FC6C466576255DA132908A12AC1674C", | ||
"part_set_header": { | ||
"total": 1, | ||
"hash": "BBA710736635FA20CDB4F48732563869E90871D31FE9E7DE3D900CD4334D8775" | ||
} | ||
}, | ||
"block": { | ||
"header": { | ||
"version": { | ||
"block": "10", | ||
"app": "1" | ||
}, | ||
"chain_id": "dockerchain", | ||
"height": "10", | ||
"time": "2020-03-15T16:57:08.151Z", | ||
"last_block_id": { | ||
"hash": "760E050B2404A4BC661635CA552FF45876BCD927C367ADF88961E389C01D32FF", | ||
"part_set_header": { | ||
"total": 1, | ||
"hash": "485070D01F9543827B3F9BAF11BDCFFBFD2BDED0B63D7192FA55649B94A1D5DE" | ||
} | ||
}, | ||
"last_commit_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"data_hash": "", | ||
"validators_hash": "3C0A744897A1E0DBF1DEDE1AF339D65EDDCF10E6338504368B20C508D6D578DC", | ||
"next_validators_hash": "3C0A744897A1E0DBF1DEDE1AF339D65EDDCF10E6338504368B20C508D6D578DC", | ||
"consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", | ||
"app_hash": "0000000000000000", | ||
"last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", | ||
"evidence_hash": "", | ||
"proposer_address": "12CC3970B3AE9F19A4B1D98BE1799F2CB923E0A3" | ||
}, | ||
"data": { | ||
"txs": null | ||
}, | ||
"evidence": { | ||
"evidence": null | ||
}, | ||
"last_commit": { | ||
"height": "9", | ||
"round": 0, | ||
"block_id": { | ||
"hash": "760E050B2404A4BC661635CA552FF45876BCD927C367ADF88961E389C01D32FF", | ||
"part_set_header": { | ||
"total": 1, | ||
"hash": "485070D01F9543827B3F9BAF11BDCFFBFD2BDED0B63D7192FA55649B94A1D5DE" | ||
} | ||
}, | ||
"signatures": [ | ||
{ | ||
"block_id_flag": 2, | ||
"validator_address": "12CC3970B3AE9F19A4B1D98BE1799F2CB923E0A3", | ||
"timestamp": "2020-03-15T16:57:08.151Z", | ||
"signature": "GRBX/UNaf19vs5byJfAuXk2FQ05soOHmaMFCbrNBhHdNZtFKHp6J9eFwZrrG+YCxKMdqPn2tQWAes6X8kpd1DA==" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"total_count": "1" | ||
} | ||
} |
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,11 @@ | ||
{ | ||
"id": "9ee74828-e8f1-429d-9d53-254c833bae00", | ||
"jsonrpc": "2.0", | ||
"method": "block_search", | ||
"params": { | ||
"order_by": "asc", | ||
"page": "1", | ||
"per_page": "10", | ||
"query": "block.height > 1" | ||
} | ||
} |
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