casper_client/rpcs/v1_4_5/
get_block.rs

1use serde::{Deserialize, Serialize};
2
3use casper_types::ProtocolVersion;
4
5use crate::{rpcs::common::BlockIdentifier, types::Block};
6
7pub(crate) const GET_BLOCK_METHOD: &str = "chain_get_block";
8
9#[derive(Serialize, Deserialize, Debug)]
10#[serde(deny_unknown_fields)]
11pub(crate) struct GetBlockParams {
12    block_identifier: BlockIdentifier,
13}
14
15impl GetBlockParams {
16    pub(crate) fn new(block_identifier: BlockIdentifier) -> Self {
17        GetBlockParams { block_identifier }
18    }
19}
20
21/// The `result` field of a successful JSON-RPC response to a `chain_get_block` request.
22#[derive(Serialize, Deserialize, Debug)]
23#[serde(deny_unknown_fields)]
24pub struct GetBlockResult {
25    /// The JSON-RPC server version.
26    pub api_version: ProtocolVersion,
27    /// The block, if found.
28    pub block: Option<Block>,
29}