coinbase_mesh/models/
network_status_response.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/// NetworkStatusResponse : NetworkStatusResponse contains basic information about the node's view of a blockchain network. It is assumed that any BlockIdentifier.Index less than or equal to CurrentBlockIdentifier.Index can be queried.  If a Rosetta implementation prunes historical state, it should populate the optional `oldest_block_identifier` field with the oldest block available to query. If this is not populated, it is assumed that the `genesis_block_identifier` is the oldest queryable block.  If a Rosetta implementation performs some pre-sync before it is possible to query blocks, sync_status should be populated so that clients can still monitor healthiness. Without this field, it may appear that the implementation is stuck syncing and needs to be terminated. 
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct NetworkStatusResponse {
17    #[serde(rename = "current_block_identifier")]
18    pub current_block_identifier: Box<models::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 = "current_block_timestamp")]
21    pub current_block_timestamp: i64,
22    #[serde(rename = "genesis_block_identifier")]
23    pub genesis_block_identifier: Box<models::BlockIdentifier>,
24    #[serde(rename = "oldest_block_identifier", skip_serializing_if = "Option::is_none")]
25    pub oldest_block_identifier: Option<Box<models::BlockIdentifier>>,
26    #[serde(rename = "sync_status", skip_serializing_if = "Option::is_none")]
27    pub sync_status: Option<Box<models::SyncStatus>>,
28    #[serde(rename = "peers", skip_serializing_if = "Option::is_none")]
29    pub peers: Option<Vec<models::Peer>>,
30}
31
32impl NetworkStatusResponse {
33    /// NetworkStatusResponse contains basic information about the node's view of a blockchain network. It is assumed that any BlockIdentifier.Index less than or equal to CurrentBlockIdentifier.Index can be queried.  If a Rosetta implementation prunes historical state, it should populate the optional `oldest_block_identifier` field with the oldest block available to query. If this is not populated, it is assumed that the `genesis_block_identifier` is the oldest queryable block.  If a Rosetta implementation performs some pre-sync before it is possible to query blocks, sync_status should be populated so that clients can still monitor healthiness. Without this field, it may appear that the implementation is stuck syncing and needs to be terminated. 
34    pub fn new(current_block_identifier: models::BlockIdentifier, current_block_timestamp: i64, genesis_block_identifier: models::BlockIdentifier) -> NetworkStatusResponse {
35        NetworkStatusResponse {
36            current_block_identifier: Box::new(current_block_identifier),
37            current_block_timestamp,
38            genesis_block_identifier: Box::new(genesis_block_identifier),
39            oldest_block_identifier: None,
40            sync_status: None,
41            peers: None,
42        }
43    }
44}
45