rosetta_types/block.rs
1/*
2 * Rosetta
3 *
4 * Build Once. Integrate Your Blockchain Everywhere.
5 *
6 * The version of the OpenAPI document: 1.4.13
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// Block : Blocks contain an array of Transactions that occurred at a particular BlockIdentifier. A hard requirement for blocks returned by Rosetta implementations is that they MUST be _inalterable_: once a client has requested and received a block identified by a specific BlockIndentifier, all future calls for that same BlockIdentifier must return the same block contents.
12
13#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
14pub struct Block {
15 #[serde(rename = "block_identifier")]
16 pub block_identifier: crate::BlockIdentifier,
17 #[serde(rename = "parent_block_identifier")]
18 pub parent_block_identifier: crate::BlockIdentifier,
19 /// The timestamp of the block in milliseconds since the Unix Epoch. The timestamp is stored in milliseconds because some blockchains produce blocks more often than once a second.
20 #[serde(rename = "timestamp")]
21 pub timestamp: i64,
22 #[serde(rename = "transactions")]
23 pub transactions: Vec<crate::Transaction>,
24 #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
25 pub metadata: Option<serde_json::Value>,
26}
27
28impl Block {
29 /// Blocks contain an array of Transactions that occurred at a particular BlockIdentifier. A hard requirement for blocks returned by Rosetta implementations is that they MUST be _inalterable_: once a client has requested and received a block identified by a specific BlockIndentifier, all future calls for that same BlockIdentifier must return the same block contents.
30 pub fn new(
31 block_identifier: crate::BlockIdentifier,
32 parent_block_identifier: crate::BlockIdentifier,
33 timestamp: i64,
34 transactions: Vec<crate::Transaction>,
35 ) -> Block {
36 Block {
37 block_identifier,
38 parent_block_identifier,
39 timestamp,
40 transactions,
41 metadata: None,
42 }
43 }
44}