coinbase_mesh/models/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
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// 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.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Block {
17 #[serde(rename = "block_identifier")]
18 pub block_identifier: Box<models::BlockIdentifier>,
19 #[serde(rename = "parent_block_identifier")]
20 pub parent_block_identifier: Box<models::BlockIdentifier>,
21 /// 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.
22 #[serde(rename = "timestamp")]
23 pub timestamp: i64,
24 #[serde(rename = "transactions")]
25 pub transactions: Vec<models::Transaction>,
26 #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
27 pub metadata: Option<serde_json::Value>,
28}
29
30impl Block {
31 /// 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.
32 pub fn new(block_identifier: models::BlockIdentifier, parent_block_identifier: models::BlockIdentifier, timestamp: i64, transactions: Vec<models::Transaction>) -> Block {
33 Block {
34 block_identifier: Box::new(block_identifier),
35 parent_block_identifier: Box::new(parent_block_identifier),
36 timestamp,
37 transactions,
38 metadata: None,
39 }
40 }
41}
42