Skip to main content

blockfrost_openapi/models/
block_content.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5pub struct BlockContent {
6    /// Block creation time in UNIX time
7    #[serde(rename = "time")]
8    pub time: i32,
9    /// Block number
10    #[serde(rename = "height", deserialize_with = "Option::deserialize")]
11    pub height: Option<i32>,
12    /// Hash of the block
13    #[serde(rename = "hash")]
14    pub hash: String,
15    /// Slot number
16    #[serde(rename = "slot", deserialize_with = "Option::deserialize")]
17    pub slot: Option<i32>,
18    /// Epoch number
19    #[serde(rename = "epoch", deserialize_with = "Option::deserialize")]
20    pub epoch: Option<i32>,
21    /// Slot within the epoch
22    #[serde(rename = "epoch_slot", deserialize_with = "Option::deserialize")]
23    pub epoch_slot: Option<i32>,
24    /// Bech32 ID of the slot leader or specific block description in case there is no slot leader
25    #[serde(rename = "slot_leader")]
26    pub slot_leader: String,
27    /// Block size in Bytes
28    #[serde(rename = "size")]
29    pub size: i32,
30    /// Number of transactions in the block
31    #[serde(rename = "tx_count")]
32    pub tx_count: i32,
33    /// Total output within the block in Lovelaces
34    #[serde(rename = "output", deserialize_with = "Option::deserialize")]
35    pub output: Option<String>,
36    /// Total fees within the block in Lovelaces
37    #[serde(rename = "fees", deserialize_with = "Option::deserialize")]
38    pub fees: Option<String>,
39    /// VRF key of the block
40    #[serde(rename = "block_vrf", deserialize_with = "Option::deserialize")]
41    pub block_vrf: Option<String>,
42    /// The hash of the operational certificate of the block producer
43    #[serde(rename = "op_cert", deserialize_with = "Option::deserialize")]
44    pub op_cert: Option<String>,
45    /// The value of the counter used to produce the operational certificate
46    #[serde(rename = "op_cert_counter", deserialize_with = "Option::deserialize")]
47    pub op_cert_counter: Option<String>,
48    /// Hash of the previous block
49    #[serde(rename = "previous_block", deserialize_with = "Option::deserialize")]
50    pub previous_block: Option<String>,
51    /// Hash of the next block
52    #[serde(rename = "next_block", deserialize_with = "Option::deserialize")]
53    pub next_block: Option<String>,
54    /// Number of block confirmations
55    #[serde(rename = "confirmations")]
56    pub confirmations: i32,
57}
58
59impl BlockContent {
60    pub fn new(time: i32, height: Option<i32>, hash: String, slot: Option<i32>, epoch: Option<i32>, epoch_slot: Option<i32>, slot_leader: String, size: i32, tx_count: i32, output: Option<String>, fees: Option<String>, block_vrf: Option<String>, op_cert: Option<String>, op_cert_counter: Option<String>, previous_block: Option<String>, next_block: Option<String>, confirmations: i32) -> BlockContent {
61        BlockContent {
62            time,
63            height,
64            hash,
65            slot,
66            epoch,
67            epoch_slot,
68            slot_leader,
69            size,
70            tx_count,
71            output,
72            fees,
73            block_vrf,
74            op_cert,
75            op_cert_counter,
76            previous_block,
77            next_block,
78            confirmations,
79        }
80    }
81}
82