cometbft_rpc/endpoint/
block_by_hash.rs1use cometbft::{
4 block::{self, Block},
5 Hash,
6};
7use serde::{Deserialize, Serialize};
8
9use crate::{dialect::Dialect, request::RequestMessage};
10
11#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
13pub struct Request {
14 #[serde(default)]
22 #[serde(with = "crate::serializers::opt_tm_hash_base64")]
23 pub hash: Option<Hash>,
24}
25
26impl Request {
27 pub fn new<H: Into<Hash>>(hash: H) -> Self {
29 Self {
30 hash: Some(hash.into()),
31 }
32 }
33}
34
35impl RequestMessage for Request {
36 fn method(&self) -> crate::Method {
37 crate::Method::BlockByHash
38 }
39}
40
41impl<S: Dialect> crate::Request<S> for Request {
42 type Response = Response;
43}
44
45impl<S: Dialect> crate::SimpleRequest<S> for Request {
46 type Output = Response;
47}
48
49#[derive(Clone, Debug, Deserialize, Serialize)]
51pub struct Response {
52 pub block_id: block::Id,
54
55 pub block: Option<Block>,
57}
58
59impl crate::Response for Response {}